From 73a76a9d5b9825a3dc396f49d76ddc5c303fce40 Mon Sep 17 00:00:00 2001 From: marekhanzlik Date: Fri, 4 Apr 2025 14:59:09 +0200 Subject: [PATCH] feat(s3): allow disabling upload checksum (#804) * S3 - toggle useChecksum * Update frontend/src/i18n/translations/en-US.ts --------- Co-authored-by: Elias Schneider --- backend/prisma/seed/config.seed.ts | 4 ++++ backend/src/file/s3.service.ts | 4 ++++ frontend/src/i18n/translations/cs-CZ.ts | 4 +++- frontend/src/i18n/translations/en-US.ts | 2 ++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/backend/prisma/seed/config.seed.ts b/backend/prisma/seed/config.seed.ts index c04222e..6fd5564 100644 --- a/backend/prisma/seed/config.seed.ts +++ b/backend/prisma/seed/config.seed.ts @@ -349,6 +349,10 @@ export const configVariables = { defaultValue: "", obscured: true, }, + useChecksum: { + type: "boolean", + defaultValue: "true", + }, }, legal: { enabled: { diff --git a/backend/src/file/s3.service.ts b/backend/src/file/s3.service.ts index de839dc..7a103a7 100644 --- a/backend/src/file/s3.service.ts +++ b/backend/src/file/s3.service.ts @@ -275,6 +275,8 @@ export class S3FileService { } getS3Instance(): S3Client { + const checksumCalculation = this.config.get("s3.useChecksum") === true ? null : "WHEN_REQUIRED"; + return new S3Client({ endpoint: this.config.get("s3.endpoint"), region: this.config.get("s3.region"), @@ -283,6 +285,8 @@ export class S3FileService { secretAccessKey: this.config.get("s3.secret"), }, forcePathStyle: true, + requestChecksumCalculation: checksumCalculation, + responseChecksumValidation: checksumCalculation, }); } diff --git a/frontend/src/i18n/translations/cs-CZ.ts b/frontend/src/i18n/translations/cs-CZ.ts index f4ba7a5..d6064dc 100644 --- a/frontend/src/i18n/translations/cs-CZ.ts +++ b/frontend/src/i18n/translations/cs-CZ.ts @@ -465,6 +465,8 @@ export default { "admin.config.s3.key.description": "The key which allows you to access the S3 bucket.", "admin.config.s3.secret": "Secret", "admin.config.s3.secret.description": "The secret which allows you to access the S3 bucket.", + "admin.config.s3.use-checksum": "Použít checksum", + "admin.config.s3.use-checksum.description": "Vypněte pro backendy které nepodporují checksum (např. B2)", "admin.config.category.legal": "Legal", "admin.config.legal.enabled": "Enable legal notices", "admin.config.legal.enabled.description": "Whether to show a link to imprint and privacy policy in the footer.", @@ -529,4 +531,4 @@ export default { "common.error.exact-length": "Musí mít přesně {length} znaků", "common.error.invalid-number": "Musí být číslo", "common.error.field-required": "Toto pole je povinné" -}; \ No newline at end of file +}; diff --git a/frontend/src/i18n/translations/en-US.ts b/frontend/src/i18n/translations/en-US.ts index 0a04a5c..a078d2e 100644 --- a/frontend/src/i18n/translations/en-US.ts +++ b/frontend/src/i18n/translations/en-US.ts @@ -655,6 +655,8 @@ export default { "admin.config.s3.key.description": "The key which allows you to access the S3 bucket.", "admin.config.s3.secret": "Secret", "admin.config.s3.secret.description": "The secret which allows you to access the S3 bucket.", + "admin.config.s3.use-checksum": "Use checksum", + "admin.config.s3.use-checksum.description": "Turn off for backends that do not support checksum (e.g. B2).", "admin.config.category.legal": "Legal", "admin.config.legal.enabled": "Enable legal notices",