com.qcloud.cos.example.TestMain Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hadoop-cos Show documentation
Show all versions of hadoop-cos Show documentation
This module contains code to support integration with Tencent Cloud COS.
It also declares the dependencies needed to work with COS.
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();
}
}