All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.qcloud.cos.example.TestMain Maven / Gradle / Ivy

Go to download

This module contains code to support integration with Tencent Cloud COS. It also declares the dependencies needed to work with COS.

There is a newer version: 8.2.7
Show newest version
package com.qcloud.cos.example;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

public class TestMain {
    private static final String COSN_URI = "cosn://hdfs-test-1252681929/";
    public static void main(String[] args) throws URISyntaxException, IOException {
        Configuration configuration = new Configuration();
        configuration.set("fs.cosn.userinfo.secretId", "AKIDMVVJ7oKky9HD3jdFdlTClBQcouthKm5M");
        configuration.set("fs.cosn.userinfo.secretKey", "b3GF0fLyWupcQH2eEd4Lb1W0UpW1UBoZ");
        configuration.set("fs.cosn.bucket.region", "ap-guangzhou");
        configuration.set("fs.cosn.impl", "org.apache.hadoop.fs.CosFileSystem");
        FileSystem fs = FileSystem.get(new URI(COSN_URI), configuration);
        String otherUri = "cosn://goosefs-test-1252681929/";
        fs.listStatus(new Path("/directory"));
        fs.close();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy