aliyun / alibabacloud-oss-sdk

The OSS SDK. Powered by Darabonba.
Apache License 2.0
20 stars 8 forks source link

Alibaba OSS SDK Java is not compatible with AWS S3 #293

Open wushilin opened 5 days ago

wushilin commented 5 days ago

If OSS SDK Java try to add usermeta with key name contains '_', the put request will fail.

Example:

 com.amazonaws.services.s3.model.ObjectMetadata s3ObjMetadata = new ObjectMetadata();
        //s3ObjMetadata.setHeader("x-amz-checksum-crc32c","12341");
        s3ObjMetadata.setSSEAlgorithm("AES256");
        HashMap<String, String> userMeta = new HashMap<>();
        userMeta.put("tmp_test", "18"); // this is the issue
        s3ObjMetadata.setUserMetadata(userMeta);
        s3ObjMetadata.setContentLength(new File("big.img").length());
        //s3ObjMetadata.setSSEAlgorithm("aws:kms");
        final PutObjectRequest request = new PutObjectRequest(bucket, "big.img", new File("big.img"))
                .withMetadata(s3ObjMetadata);
        PutObjectResult putResult = s3Client.putObject(request);

Expected behavior: the put request will succeed.

Actual behavior: xception in thread "main" com.amazonaws.SdkClientException: Unable to execute HTTP request: Connection or outbound has closed at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleRetryableException(AmazonHttpClient.java:1219) at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1165) at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:814)

This makes OSS not really compatible with AWS S3.

github-actions[bot] commented 5 days ago

感谢您为阿里云 OSS SDK 提交宝贵的建议