Skip to content

docs(aws-sdk-js-v3): corrected Content-Type presigning examples#27832

Open
BoogeyMan24 wants to merge 3 commits intocloudflare:productionfrom
BoogeyMan24:production
Open

docs(aws-sdk-js-v3): corrected Content-Type presigning examples#27832
BoogeyMan24 wants to merge 3 commits intocloudflare:productionfrom
BoogeyMan24:production

Conversation

@BoogeyMan24
Copy link

Summary

The documentation was stating that:

// Generate presigned URL for writing (PUT)
// Specify ContentType to restrict uploads to a specific file type
const putUrl = await getSignedUrl(
	S3,
	new PutObjectCommand({
		Bucket: "my-bucket",
		Key: "image.png",
		ContentType: "image/png",
	}),
	{ expiresIn: 3600 },
);

However, ContentType header is NOT signed by default and signableHeaders must be added for the header to be signed:

// Generate presigned URL for writing (PUT)
// Specify ContentType and add it to signableHeaders to restrict uploads to a specific file type
const putUrl = await getSignedUrl(
	S3,
	new PutObjectCommand({
		Bucket: "my-bucket",
		Key: "image.png",
		ContentType: "image/png",
	}),
	{ 
		expiresIn: 3600,
		signableHeaders: new Set(["content-type"]),
	},
);

This PR adds the required signableHeaders to the examples in the documentation so that Content-Type is signed.
Source: https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-s3-request-presigner/

Screenshots (optional)

none

Documentation checklist

not sure how to make a changelog. If its necessary, how do I do it?

Content-Type is not signed by default. It must be added to signableHeaders for it to be signed. Added a warning and a link to official docs to ensure people protect their urls correctly.
…/s3/presigned-ruls

Updated the presigned URL generation example to include signableHeaders for ContentType restriction.
Before: "Specify ContentTypea and add it to the signableHeaders..."
Now: "Specify ContentType and add it to signableHeaders"
@BoogeyMan24
Copy link
Author

bump

@github-actions
Copy link
Contributor

Hey there, we've marked this pull request as stale because there's no recent activity on it. This label is helps us identify PRs that might need updates (or to be closed out by our team if no longer relevant).

@github-actions github-actions bot added the stale label Feb 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants