获取文件链接
更新时间: 2020-03-24
本节主要介绍如何获取文件链接。
以下代码用于获取文件链接:
// Endpoint以华北三为例,其它Region请按实际情况填写。
String endpoint = "oss.cn-north-3.inspurcloudoss.com";
String accessKey = "<yourAccessKey>";
String secretKey = "<yourSecretKey>";
String bucketName = "<yourBucketName>";
String key = "<yourObjectName>";
//创建OSSClient实例
OSSClientImpl ossClient = new OSSClientImpl(endpoint, accessKey, secretKey);
//获取文件链接
URL url = ossClient.getUrl(bucketName, key);
System.out.println("Getting Url: " + url);