From 5c07051ce3f498a83985f84d1d1e6baee2a38222 Mon Sep 17 00:00:00 2001 From: Yunus Date: Sun, 8 Dec 2024 12:00:59 +0700 Subject: [PATCH] Fix filename extension not correctly set in some browser --- server/api/artifacts/download-artifact.get.ts | 2 +- server/services/s3fetch.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/server/api/artifacts/download-artifact.get.ts b/server/api/artifacts/download-artifact.get.ts index 8ec65f8..e850cd3 100644 --- a/server/api/artifacts/download-artifact.get.ts +++ b/server/api/artifacts/download-artifact.get.ts @@ -27,7 +27,7 @@ export const getArtifactFromInternal = async ( const { assets } = getStorageKeys(app.organizationsId!, app.id, actuallyHasApk ? detailArtifact.fileObjectApkKey! : detailArtifact.fileObjectKey) const s3 = new S3Fetch() const artifactExt = actuallyHasApk ? 'apk' : detailArtifact.extension - const signedUrl = await s3.getSignedUrlGetObject(assets, 1800, `attachment; filename ="${app.name}${artifactExt ? `.${artifactExt}` : ''}"`) + const signedUrl = await s3.getSignedUrlGetObject(assets, 1800, `attachment; filename="${encodeURIComponent(app.name)}${artifactExt ? `.${artifactExt}` : ''}"`) return { signedUrl, userOrg: org, diff --git a/server/services/s3fetch.ts b/server/services/s3fetch.ts index 0a0f63a..690c2f5 100644 --- a/server/services/s3fetch.ts +++ b/server/services/s3fetch.ts @@ -15,7 +15,7 @@ export class S3Fetch { async getSignedUrlGetObject(key: string, expiresIn: number, contentDisposition: string): Promise { const { client, S3_ENDPOINT } = createAwsClient() - const signedUrl = await client.sign(`${S3_ENDPOINT}/${s3BucketName}/${key}?X-Amz-Expires=${expiresIn}&response-content-disposition=${contentDisposition}`, { + const signedUrl = await client.sign(`${S3_ENDPOINT}/${s3BucketName}/${key}?X-Amz-Expires=${expiresIn}&response-content-disposition=${contentDisposition}&response-content-type=application/octet-stream`, { aws: { signQuery: true, },