build: affine Node.js server charts (#2895)

This commit is contained in:
LongYinan
2023-06-29 22:02:46 +08:00
committed by Alex Yang
parent 0bdecc776d
commit 03dea53b30
43 changed files with 1112 additions and 124 deletions
+8 -1
View File
@@ -8,7 +8,14 @@ export const S3_SERVICE = Symbol('S3_SERVICE');
export const S3: FactoryProvider<S3Client> = {
provide: S3_SERVICE,
useFactory: (config: Config) => {
const s3 = new S3Client(config.objectStorage.config);
const s3 = new S3Client({
region: 'auto',
endpoint: `https://${config.objectStorage.r2.accountId}.r2.cloudflarestorage.com`,
credentials: {
accessKeyId: config.objectStorage.r2.accessKeyId,
secretAccessKey: config.objectStorage.r2.secretAccessKey,
},
});
return s3;
},
inject: [Config],
@@ -15,11 +15,11 @@ export class StorageService {
) {}
async uploadFile(key: string, file: FileUpload) {
if (this.config.objectStorage.enable) {
if (this.config.objectStorage.r2.enabled) {
await this.s3.send(
new PutObjectCommand({
Body: file.createReadStream(),
Bucket: this.config.objectStorage.config.bucket,
Bucket: this.config.objectStorage.r2.bucket,
Key: key,
})
);