Generate a presigned S3 upload URL
getSignedUrlPromise moves to the separate @aws-sdk/s3-request-presigner package, and the Expires parameter becomes the expiresIn option.
import S3 from "aws-sdk/clients/s3";
const s3 = new S3({ region: "us-east-1" });
export function getUploadUrl(key) {
return s3.getSignedUrlPromise("putObject", {
Bucket: "uploads",
Key: key,
ContentType: "image/png",
Expires: 900,
});
}
import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3";
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
const client = new S3Client({ region: "us-east-1" });
export function getUploadUrl(key) {
const command = new PutObjectCommand({
Bucket: "uploads",
Key: key,
ContentType: "image/png",
});
return getSignedUrl(client, command, { expiresIn: 900 });
}