Skip to content

PresignPutObject

Source: src/AWS/S3/PresignPutObject.ts

Mint presigned upload (PUT) URLs for objects in a Bucket.

Presigning is a pure SigV4 computation performed client-side with the Function’s own credentials — no S3 API call is made. Because the URL inherits the signer’s IAM permissions, the binding grants s3:PutObject on the bucket’s objects to the host Function.

Mint a presigned PUT URL

const presignPutObject = yield* S3.PresignPutObject(bucket);
const url = yield* presignPutObject({ key: "uploads/avatar.png" });
// hand `url` to a browser — it can PUT the object without AWS credentials

Pin the uploaded Content-Type

const url = yield* presignPutObject({
key: "uploads/avatar.png",
expiresIn: 300, // valid for 5 minutes
contentType: "image/png", // uploader must send Content-Type: image/png
});