Skip to content

S3 Uploading pre-signed URL with signature v4, Content Disposition causes signature mismatch #1804

@CanGokdere

Description

@CanGokdere

I am currently using pre-signed uploading to directly upload from browser to s3. I can upload with no problems when I do not set the content disposition in options, for instance:

var s3upload = new AWS.S3({
signatureVersion: 'v4',
accessKeyId: process.env.S3_UPLOAD_CLIENT_KEY,
secretAccessKey: process.env.S3_UPLOAD_CLIENT_SECRET,
});
var baseOptions = {
Bucket: process.env.S3_BUCKET,
ACL: 'public-read',
Key: uuidv4(),
}

This works fine, http request:
works1

This also works fine when I set encryption

var baseOptions = {
Bucket: process.env.S3_BUCKET,
ACL: 'public-read',
Key: uuidv4(),
ServerSideEncryption: 'AES256'
}
works2

But if I add content disposition to options, I always get Signature mismatch

var baseOptions = {
Bucket: process.env.S3_BUCKET,
ACL: 'public-read',
Key: uuidv4(),
ContentDisposition: 'attachment',
ServerSideEncryption: 'AES256'
}

notworking

I get the following response:
<?xml version="1.0" encoding="UTF-8"?> <Error><Code>SignatureDoesNotMatch</Code><Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message>

What is the problem and how can I fix it ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions