From 6479a2605667dad25c3ac228e52a01bda5a6ca1e Mon Sep 17 00:00:00 2001 From: lzanatta <46678005+lzanatta@users.noreply.github.com> Date: Tue, 4 Aug 2026 13:22:14 -0300 Subject: [PATCH 1/3] feat: Support native args on S3 download --- docs/aws/s3.md | 5 +++++ src/aws/s3/get_signed_download_url.js | 8 ++++++-- src/aws/s3/get_signed_download_url.test.js | 13 +++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/docs/aws/s3.md b/docs/aws/s3.md index 605d68b..145c570 100644 --- a/docs/aws/s3.md +++ b/docs/aws/s3.md @@ -204,6 +204,10 @@ const { s3 } = aws; const url = await s3.getSignedDownloadUrl( 'my-bucket', 'my/key.json', 360 ); console.log( url ); + +// With native args — force download with a filename hint +const url = await s3.getSignedDownloadUrl( 'my-bucket', 'my/key.json', 360, { ResponseContentDisposition: 'attachment; filename="test.txt"' } ); +console.log( url ); ``` #### Arguments @@ -213,6 +217,7 @@ console.log( url ); |bucket|String|The the s3 bucket of the object to download|| |key|String|The the s3 key of the object to download|| |expiration|number|The number of seconds before the presigned URL expires|| +|nativeArgs|Object|All `client-s3` SDK [GetObjectCommand arguments](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-s3/Class/GetObjectCommand/) except `Key` and `Bucket`, which are defined by the previous arguments|| #### Return diff --git a/src/aws/s3/get_signed_download_url.js b/src/aws/s3/get_signed_download_url.js index 1efc6ca..21c0e3d 100644 --- a/src/aws/s3/get_signed_download_url.js +++ b/src/aws/s3/get_signed_download_url.js @@ -1,8 +1,12 @@ import { getSignedUrl } from '@aws-sdk/s3-request-presigner'; import { GetObjectCommand } from '@aws-sdk/client-s3'; -export const getSignedDownloadUrl = async ( client, bucket, key, expiration ) => { - const getObjectCmd = new GetObjectCommand( { Bucket: bucket, Key: key } ); +export const getSignedDownloadUrl = async ( client, bucket, key, expiration, nativeArgs ) => { + const getObjectCmd = new GetObjectCommand( { + ...nativeArgs, + Bucket: bucket, + Key: key + } ); const url = await getSignedUrl( client, getObjectCmd, { expiresIn: expiration } ); return url; }; diff --git a/src/aws/s3/get_signed_download_url.test.js b/src/aws/s3/get_signed_download_url.test.js index dbf0f18..f7194cf 100644 --- a/src/aws/s3/get_signed_download_url.test.js +++ b/src/aws/s3/get_signed_download_url.test.js @@ -56,4 +56,17 @@ describe( 'S3 Get Signed Download Url Spec', () => { strictEqual( getSignedUrlMock.mock.calls.length, 1 ); deepStrictEqual( getSignedUrlMock.mock.calls[0].arguments, [ client, commandInstance, { expiresIn: expiration } ] ); } ); + + it( 'Should get a signed download url for a file from S3 with native args and return its content', async () => { + getSignedUrlMock.mock.mockImplementation( () => response ); + + const contentDisposition = 'attachment; filename="test.txt"'; + const result = await getSignedDownloadUrl( client, bucket, key, expiration, { ResponseContentDisposition: contentDisposition } ); + + strictEqual( result, response ); + strictEqual( constructorMock.mock.calls.length, 1 ); + deepStrictEqual( constructorMock.mock.calls[0].arguments[0], { Key: key, Bucket: bucket, ResponseContentDisposition: contentDisposition } ); + strictEqual( getSignedUrlMock.mock.calls.length, 1 ); + deepStrictEqual( getSignedUrlMock.mock.calls[0].arguments, [ client, commandInstance, { expiresIn: expiration } ] ); + } ); } ); From 9710e6d29abc160280b937652e0394f7acafc82e Mon Sep 17 00:00:00 2001 From: lzanatta <46678005+lzanatta@users.noreply.github.com> Date: Tue, 4 Aug 2026 13:23:21 -0300 Subject: [PATCH 2/3] Updated docs --- docs/aws/s3.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/aws/s3.md b/docs/aws/s3.md index 145c570..c61391a 100644 --- a/docs/aws/s3.md +++ b/docs/aws/s3.md @@ -205,7 +205,7 @@ const { s3 } = aws; const url = await s3.getSignedDownloadUrl( 'my-bucket', 'my/key.json', 360 ); console.log( url ); -// With native args — force download with a filename hint +// With native args const url = await s3.getSignedDownloadUrl( 'my-bucket', 'my/key.json', 360, { ResponseContentDisposition: 'attachment; filename="test.txt"' } ); console.log( url ); ``` From 46df45eeec7305cadd007936e424b2b1f7f92150 Mon Sep 17 00:00:00 2001 From: lzanatta <46678005+lzanatta@users.noreply.github.com> Date: Tue, 4 Aug 2026 13:25:17 -0300 Subject: [PATCH 3/3] Updated docs --- docs/aws/s3.md | 2 +- src/aws/s3/get_signed_download_url.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/aws/s3.md b/docs/aws/s3.md index c61391a..2b43e85 100644 --- a/docs/aws/s3.md +++ b/docs/aws/s3.md @@ -206,7 +206,7 @@ const url = await s3.getSignedDownloadUrl( 'my-bucket', 'my/key.json', 360 ); console.log( url ); // With native args -const url = await s3.getSignedDownloadUrl( 'my-bucket', 'my/key.json', 360, { ResponseContentDisposition: 'attachment; filename="test.txt"' } ); +const url = await s3.getSignedDownloadUrl( 'my-bucket', 'my/key.json', 360, { ResponseContentDisposition: 'attachment; filename="key.json"' } ); console.log( url ); ``` diff --git a/src/aws/s3/get_signed_download_url.test.js b/src/aws/s3/get_signed_download_url.test.js index f7194cf..f58611f 100644 --- a/src/aws/s3/get_signed_download_url.test.js +++ b/src/aws/s3/get_signed_download_url.test.js @@ -60,7 +60,7 @@ describe( 'S3 Get Signed Download Url Spec', () => { it( 'Should get a signed download url for a file from S3 with native args and return its content', async () => { getSignedUrlMock.mock.mockImplementation( () => response ); - const contentDisposition = 'attachment; filename="test.txt"'; + const contentDisposition = 'attachment; filename="key"'; const result = await getSignedDownloadUrl( client, bucket, key, expiration, { ResponseContentDisposition: contentDisposition } ); strictEqual( result, response );