Lalit lms
Lalit lms

Reputation: 41

Getting invalid argument error while using s3 presigned url for downloading?

generated presigned url for preview which is working. For downloading I had override the response header i.e., content-type to "application/octet-stream" and content-disposition.But getting invalid argument error while hitting the url.

InvalidArgument response-content-disposition\u003dattachment; filename="customer master.pdf"\u0026response-content-type\u003d"application/octet-stream"\u0026X-Amz-Algorithm\u003dAWS4-HMAC-SHA256\u0026X-Amz-Date\u003d20220307T101749Z\u0026X-Amz-SignedHeaders\u003dhost\u0026X-Amz-Expires\u003d3600\u0026X-Amz-Credential\u003dAKIAQWQ6NPLXN6RAKTA6/20220307/us-east-1/s3/aws4_request\u0026X-Amz-Signature\u003d427c93aad19403ba6ecde71830cbcaefd5c36cd00caa81a193053f7d396de0e7 is not in the set of overridable response headers. Please refer to the S3 API documentation for a complete list of overridable response headers. response-content-disposition\u003dattachment; filename="Reltio Data Model - customer master.pdf"\u0026response-content-type\u003d"application/octet-stream"\u0026X-Amz-Algorithm\u003dAWS4-HMAC-SHA256\u0026X-Amz-Date\u003d20220307T101749Z\u0026X-Amz-SignedHeaders\u003dhost\u0026X-Amz-Expires\u003d3600\u0026X-Amz-Credential\u003dAKIAQWQ6NPLXN6RAKTA6/20220307/us-east-1/s3/aws4_request\u0026X-Amz-Signature\u003d427c93aad19403ba6ecde71830cbcaefd5c36cd00caa81a193053f7d396de0e7 1CR9VHXFJW2JNQYH GtDJh423Tj1YCOw7VVye6kyR+AlnulsSB3YF9WdPzktRGXtzKwNKHrYlfCCMJugHgqaXHbeLNj0=

Upvotes: 1

Views: 642

Answers (1)

Vladimir Serafimov
Vladimir Serafimov

Reputation: 11

Found the solution in the AWS documentation -> Create a presigned URL:

If using the Region us-east-1, and server-side encryption with AWS KMS, you must specify Signature Version 4. Region us-east-1 defaults to Signature Version 2 unless explicitly set to Version 4 as shown below.

C# Solution

Before calling GetPreSignedURL(), set the following:

AWSConfigsS3.UseSignatureVersion4 = true;

AWS SDK UseSignatureVersion4 tooltip:

Configures if the S3 client should use Signature Version 4 signing with requests. By default, this setting is set to true which will use Signature Version 4 for all requests except presigned URL requests when the region is set to us-east-1. When UseSignatureVersion4 is explicitly set to true by directly setting this property or directly setting this property through configuration, Signature Version 4 will be used for all requests when able to do so. When this setting is false, Signature Version 2 will be used. Note that when the setting is false, Signature Version 4 may still be used by default in some cases or with some regions.

Upvotes: 1

Related Questions