Skip to content

Commit

Permalink
fix(server): disable checksum check for r2 storage when using aws-s3 …
Browse files Browse the repository at this point in the history
…sdk (#9735)
  • Loading branch information
forehalo authored Jan 16, 2025
1 parent 908afe1 commit 3828144
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/backend/server/scripts/self-host-predeploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const SELF_HOST_CONFIG_DIR = '/root/.affine/config';
function generateConfigFile() {
const content = fs.readFileSync('./dist/config/affine.js', 'utf-8');
return content.replace(
/(^\/\/#.*$)|(^\/\/\s+TODO.*$)|("use\sstrict";?)|(^.*eslint-disable.*$)/gm,
/(^\/\/#.*$)|(^\/\/\s+TODO.*$)|("use\sstrict";?)|(^.*lint-disable.*$)/gm,
''
);
}
Expand Down
4 changes: 3 additions & 1 deletion packages/backend/server/src/config/affine.self.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
/* oxlint-disable @typescript-eslint/no-non-null-assertion */
// Custom configurations for AFFiNE Cloud
// ====================================================================================
// Q: WHY THIS FILE EXISTS?
Expand Down Expand Up @@ -31,6 +31,8 @@ if (env.R2_OBJECT_STORAGE_ACCOUNT_ID) {
accessKeyId: env.R2_OBJECT_STORAGE_ACCESS_KEY_ID!,
secretAccessKey: env.R2_OBJECT_STORAGE_SECRET_ACCESS_KEY!,
},
requestChecksumCalculation: 'WHEN_REQUIRED',
responseChecksumValidation: 'WHEN_REQUIRED',
});
AFFiNE.storages.avatar.provider = 'cloudflare-r2';
AFFiNE.storages.avatar.bucket = 'account-avatar';
Expand Down
12 changes: 8 additions & 4 deletions packages/backend/server/src/config/affine.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
//
// ###############################################################
// ## AFFiNE Configuration System ##
Expand Down Expand Up @@ -99,9 +98,14 @@ AFFiNE.server.port = 3010;
// /* AWS S3 Plugin */
// /* Enable if you choose to store workspace blobs or user avatars in AWS S3 Storage Service */
// AFFiNE.use('aws-s3', {
// credentials: {
// accessKeyId: '',
// secretAccessKey: '',
// credentials: {
// accessKeyId: '',
// secretAccessKey: '',
// },
// /* Whether enable checksum calculation for request */
// /* see https://github.com/aws/aws-sdk-js-v3/issues/6810 */
// requestChecksumCalculation: 'WHEN_REQUIRED',
// responseChecksumValidation: 'WHEN_REQUIRED',
// })
// /* Update the provider of storages */
// AFFiNE.storages.blob.provider = 'cloudflare-r2';
Expand Down
2 changes: 2 additions & 0 deletions tools/cli/src/webpack/s3-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export class WebpackS3Plugin implements WebpackPluginInstance {
accessKeyId: process.env.R2_ACCESS_KEY_ID!,
secretAccessKey: process.env.R2_SECRET_ACCESS_KEY!,
},
requestChecksumCalculation: 'WHEN_REQUIRED',
responseChecksumValidation: 'WHEN_REQUIRED',
});

apply(compiler: Compiler) {
Expand Down

0 comments on commit 3828144

Please sign in to comment.