Skip to content

Commit

Permalink
Read filename from metadata (#3767)
Browse files Browse the repository at this point in the history
  • Loading branch information
Riron authored Nov 20, 2024
1 parent 590bbce commit 7d7fe46
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions libs/back/registry/src/s3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,23 @@ export async function getSignedUrlForUpload({

export async function getSignedUrlForDownload({
bucketName,
key
key,
fileName
}: {
bucketName: string;
key: string;
metadata?: Record<string, string>;
tags?: Record<string, string>;
fileName?: string;
}) {
const metadataResponse = await getFileMetadata(bucketName, key);
const metadataFileName = metadataResponse?.Metadata?.filename;

const computedFileName =
fileName ?? metadataFileName ?? `${bucketName}_${key}`;

const command = new GetObjectCommand({
Bucket: bucketName,
Key: key,
ResponseContentDisposition: `attachment; filename="${bucketName}_${key}"`
ResponseContentDisposition: `attachment; filename="${computedFileName}"`
});

const signedUrl = await getSignedUrl(registryS3Client, command, {
Expand Down

0 comments on commit 7d7fe46

Please sign in to comment.