问题描述
OSS java SDK 生成DeleteObject 接口请求的签名url
问题原因
设置 generatePresignedUrlRequest.setMethod 为DELETE的时候,执行会报错
// 创建请求。GeneratePresignedUrlRequestgeneratePresignedUrlRequest=newGeneratePresignedUrlRequest(bucketName, objectName); // 设置HttpMethod为DELETE。generatePresignedUrlRequest.setMethod(HttpMethod.DELETE); // 设置签名URL过期时间,单位为毫秒。Dateexpiration=newDate(newDate().getTime() +3600*1000); generatePresignedUrlRequest.setExpiration(expiration); // 生成签名URL。URLurl=ossClient.generatePresignedUrl(generatePresignedUrlRequest); System.out.println(url);
解决方案
找到src>main>java>com>aliyun>oss>model>GeneratePresignedUrlRequest
注释掉图中代码
if (method!=HttpMethod.GET&&method!=HttpMethod.PUT) thrownewIllegalArgumentException("Only GET or PUT is supported!");
适用于
- OSS