Skip to content

Instantly share code, notes, and snippets.

@flexicious
Last active February 12, 2023 19:01
Show Gist options
  • Save flexicious/e836c8d5fa06d713e8770b25aee06b65 to your computer and use it in GitHub Desktop.
Save flexicious/e836c8d5fa06d713e8770b25aee06b65 to your computer and use it in GitHub Desktop.
Make a signed S3 Url
import {
S3Client,
PutObjectCommand }
from "@aws-sdk/client-s3";
import {getSignedUrl} from "@aws-sdk/s3-request-presigner";
const signS3URL = async () => {
const s3Params = {
Bucket: "your-bucket",
Key: "config.json",
};
const s3 = new S3Client({})
const command = new PutObjectCommand(s3Params);
try {
const signedUrl = await getSignedUrl(s3, command, { expiresIn: 300 });
console.log(signedUrl);
} catch (err) {
console.error(err);
}
}
signS3URL();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment