# S3 Reference ## Presigned URLs (GET / PUT) ```js import { S3Client, GetObjectCommand, PutObjectCommand } from "@aws-sdk/client-s3"; import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; const client = new S3Client({ region: "us-east-1" }); // GET — default expiry 900s const getUrl = await getSignedUrl(client, new GetObjectCommand({ Bucket: "b", Key: "k" }), { expiresIn: 3600 }); // PUT const putUrl = await getSignedUrl(client, new PutObjectCommand({ Bucket: "b", Key: "k" }), { expiresIn: 3600 }); ``` Signing non-x-amz headers (e.g. Content-Type): ```js const url = await getSignedUrl(client, new PutObjectCommand({ Bucket: "b", Key: "k", ContentType: "image/png" }), { signableHeaders: new Set(["content-type"]), expiresIn: 3600, }); ``` Signing x-amz-* headers (must use `unhoistableHeaders`): ```js const url = await getSignedUrl(client, new PutObjectCommand({ Bucket: "b", Key: "k", ChecksumSHA256: sha }), { unhoistableHeaders: new Set(["x-amz-checksum-sha256"]), expiresIn: 3600, }); ``` ## Presigned POST (browser file upload) ```js import { createPresignedPost } from "@aws-sdk/s3-presigned-post"; const { url, fields } = await createPresignedPost(client, { Bucket: "b", Key: "uploads/${filename}", // ${filename} replaced by browser Expires: 600, Conditions: [["content-length-range", 0, 10485760]], Fields: { acl: "bucket-owner-full-control" }, }); // Use url + fields in an HTML