// 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類的幫助。