AmazonS3Exception: x-amz-website-redirect-location header is not supported for this operation

I have an interesting exception when trying to load data from an Android client into AWS:

com.amazonaws.services.s3.model.AmazonS3Exception: x-amz-website-redirect-location header is not supported for this operation. (Service: Amazon S3; Status Code: 400; Error Code: InvalidArgument; Request ID: E3900749ACF1D979), S3 Extended Request ID: kFjMM7JVFSOxvaKlHgM0bVM5zKZAR/0K8qeMyt44vjvtMFcGk8CxY9gDBDs0sqWmr8r2jcCyENo= 

A user located in a region of China and data uploads his under VPN (Hong Kong) to a western bucket http://currentidmedia.s3-ap-southeast-1.amazonaws.com

More details about the request below:

 PUT http://currentidmedia.s3-ap-southeast-1.amazonaws.com / Headers: (Expect: 100-continue, Content-Type: application/octet-stream, Date: Fri, 05 Jun 2015 10:13:01 GMT+00:00, Content-Length: 0, User-Agent: aws-sdk-android/2.2.1 Linux/3.4.0-g8a80a0e Dalvik/2.1.0/0 en_US com.amazonaws.mobileconnectors.s3.transfermanager.TransferManager/2.2.1, x-amz-website-redirect-location: /storage/emulated/0/DCIM/Camera/IMG_20150601_153423.jpg, Accept-Encoding: identity, Authorization: AWS AKIAIYL3TJHYVMB4SFRQ:dAkmOJxaIe5viO5kNjz74I/UKSc=, ) 

Is this a bug in the SDK, or am I not using it correctly?

UPDATE:

 // set up credentials AWSCredentials awsCredentials = new BasicAWSCredentials( awsMetadata.getAccountId(), awsMetadata.getSecretKey() ); // set up request PutObjectRequest request = new PutObjectRequest( awsMetadata.getBucketName(), FileUtil.extractNameFromPath(mediaItem.getContentUri()), mediaItem.getContentUri() ); // perform request TransferManager transferManager = new TransferManager(awsCredentials); transferManager.getAmazonS3Client().setRegion(getRegionForMedia(awsMetadata)); transferManager.upload(request, listener); 

Answer: I used PutObjectRequest incorrectly. It contains several constructors, and if you pass String to content instead of a file, you set the redirect URL instead of the data path.

However, after fixing it, I got the same SSLException error for a non-Chinese bucket. I used it under VPN and without it. You can find more details about the request below.

 PUT https://currentidmedia.s3-ap-southeast-1.amazonaws.com / Headers: (Content-MD5: GI1M/hfrwwQHvHMBlmh/lA==, Expect: 100-continue, Content-Type: image/jpeg, Date: Sat, 06 Jun 2015 08:56:31 GMT+00:00, Content-Length: 2140572, User-Agent: aws-sdk-android/2.2.1 Linux/3.4.0-g8a80a0e Dalvik/2.1.0/0 en_US com.amazonaws.mobileconnectors.s3.transfermanager.TransferManager/2.2.1, Accept-Encoding: identity, Authorization: AWS AKIAIYL3TJHYVMB4SFRQ:fqWbHO6lBPsbI6lkcaHKhms8Hkw=, ) 
0
source share
1 answer

The x-amz-website-redirect-location metadata is for a static website only. The static website has a different endpoint <bucket-name>.s3-website-<AWS-region>.amazonaws.com . See http://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteHosting.html for details. Do you mind explaining the purpose of its installation? I will see if there is an alternative.

0
source

Source: https://habr.com/ru/post/988294/


All Articles