I use the aws-sdk for java to upload a file to s3 (Frankfurt region).
ObjectMetadata omd = new ObjectMetadata();
omd.setContentDisposition("attachment;filename=\"" + someFileNameWithNonASCIIChars + "\"");
...
PutObjectRequest por = new PutObjectRequest(bucket, key, stream, omd);
s3Object.putObject(por);
The last line throws a AmazonServiceException
stating SignatureDoesNotMatch as the reason:
The request signature we calculated does not match the signature you provided.
This only happens when non-ASCII characters are in the Content-Disposition header value.
I am aware of the workaround for browsers that cannot handle utf-8 encoding decoding:
How to encode the filename parameter of Content-Disposition header in HTTP?
I can use this solution. But is this the intended result from S3? Is there some way to send UTF-8 characters in the Content-Disposition header? And then I can just let the browsers deal with the non-ASCII characters.
Also, using the *=utf-8''
workaround causes spaces to be decoded to "+" signs rather than back to spaces, which isn't ideal. It's explained here.
Thanks.