Generate Presigned Download URL
utilcn/generate-presigned-download-urlFreeUtility
Generate a presigned download URL for a file.
Install it
npx shadcn@latest add https://utilcn.dev/r/generate-presigned-download-url.jsonSource
1import { GetObjectCommand } from '@aws-sdk/client-s3';2import { getSignedUrl } from '@aws-sdk/s3-request-presigner';34import { getS3Client } from '@/registry/default/storage/s3-client';56export async function generatePresignedDownloadUrl(7 key: string,8 expiresIn = 3600,9) {10 try {11 const command = new GetObjectCommand({12 Bucket: process.env.S3_BUCKET_NAME,13 Key: key,14 });1516 const url = await getSignedUrl(getS3Client(), command, { expiresIn });17 return url;18 } catch (err) {19 console.error({ err }, 'Failed to generate download URL');20 throw new Error('Failed to generate download URL');21 }22}
What it pulls in
npm packages
Files it writes
More from utilcn
All 17 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Capitalizecapitalize | utilcn | Utilities | Free | no deps | |
| Capitalize Allcapitalize-all | utilcn | Utilities | Free | no deps | |
| Environment Server Configurationenv-server | utilcn | Utilities | Free | 1 dep | |
| Generate Presigned Upload URLgenerate-presigned-upload-url | utilcn | Utilities | Free | 2 deps · 2 files | |
| Repeat Padrepeat-pad | utilcn | Utilities | Free | no deps | |
| Reverse Stringreverse-string | utilcn | Utilities | Free | no deps | |
| To Camel Caseto-camel-case | utilcn | Utilities | Free | no deps | |
| To Kebab Caseto-kebab-case | utilcn | Utilities | Free | no deps |
