生成签名以后的URL的示例代码如下:
// Generate a presigned URL
Date expires = new Date (new Date().getTime() + 1000 * 60); // 1 minute to expire
GeneratePresignedUrlRequest generatePresignedUrlRequest =
new GeneratePresignedUrlRequest(bucketName, key);
generatePresignedUrlRequest.setExpiration(expires);
URL url = client.generatePresignedUrl(generatePresignedUrlRequest);
System.out.println(url.toString());
这段代码假定指定bucketName和key的Object已经上传到OSS,用户可以根据修改设定expires,即过期时间。更详细的操作可以参考OSSClient#generatePresignedUrl方法和GeneratePresignedUrlRequest类的帮助。
©2024 aliyunhn.com. All Rights Reserved 中科九洲科技股份有限公司-阿里云河南授权服务中心 豫B2-20080032-14 统计