Skip to content

Commit

Permalink
feat: allow additional options to be specified when generating presig…
Browse files Browse the repository at this point in the history
…ned download url
  • Loading branch information
james-hu committed Feb 21, 2024
1 parent 9f4f8b4 commit 905fca9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/s3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,15 @@ export async function putS3Object(s3: S3Client, bucket: string, key: string, con
* @param bucket Name of the bucket
* @param key Key of the object
* @param expiresIn The number of seconds before the presigned URL expires
* @param options Additional options. For example, you can specify content-disposition and content-type in it.
* @returns An URL that can be used to download the S3 object.
*/
export async function generatePresignedUrlForDownloading(s3: S3Client, bucket: string, key: string, expiresIn: number): Promise<string> {
const command = new GetObjectCommand({ Bucket: bucket, Key: key });
export async function generatePresignedUrlForDownloading(s3: S3Client, bucket: string, key: string, expiresIn: number, options?: Omit<ConstructorParameters<typeof GetObjectCommand>[0], 'Bucket'|'Key'>): Promise<string> {
const command = new GetObjectCommand({
...options,
Bucket: bucket,
Key: key,
});
return getSignedUrl(s3, command, { expiresIn });
};

Expand Down

0 comments on commit 905fca9

Please sign in to comment.