2 Answers
- Newest
- Most votes
- Most comments
0
The error message here is accurate: You're sending headers in your PUT
request that aren't in the original presigned URL. You either need put define those headers when you create the original URL (in your Lambda code) or not send the headers.
I don't think you need to send X-Amz-Credential
, X-Amz-Security-Token
, X-Amz-Expires
, X-Amz-Date
, X-Amz-Signature
and probably not X-Amz-Algorithm
either.
0
The issue was resolved by removing the ACL field being passed as a parameter to generate the presigned URL.
Old url generation code
const url = await s3client.getSignedUrlPromise("putObject", {
Bucket: s3bucketparams.bucket,
Key: `${filename}`,
ContentType: signedUrlparams.ContentType,
ACL: signedUrlparams.Acl,
Expires: signedUrlparams.signedUrlExpireSeconds,
})
New url generation code
const url = await s3client.getSignedUrlPromise("putObject", {
Bucket: s3bucketparams.bucket,
Key: `${filename}`,
ContentType: signedUrlparams.ContentType,
Expires: signedUrlparams.signedUrlExpireSeconds,
})
answered a year ago
Relevant content
- Accepted Answerasked 6 months ago
- asked 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 10 months ago
I have these headers in my presigned url from where I extract them and add it in the headers. If I don't add them in the header and just use
axios.put(presignedUrl, file)
still I get an Access Denied with no other details in the error message.
But those headers aren't in your code where you are generating the presigned URL - that's why you get the original error. Note that the credentials that you're assuming in the Lambda role are temporary - they will expire in a short period of time, perhaps shorter than before you use the presigned URL? I would go back to basics: Experiment from your development machine by creating a presigned URL with the minimum components (content type really) and get it working from there; then gradually add things; then move to Lambda. Troubleshoot this like any other problem. Start simple and work up to more complex.