Skip to content

Commit

Permalink
fix(file): set minio region
Browse files Browse the repository at this point in the history
  • Loading branch information
Menci committed Jan 3, 2023
1 parent 1f238c5 commit 04a0b28
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/file/file.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { InjectRepository, InjectDataSource } from "@nestjs/typeorm";

import { Repository, DataSource, EntityManager, In } from "typeorm";
import { v4 as UUID } from "uuid";
import { Client as MinioClient } from "minio";
import { Client as MinioClient, ClientOptions } from "minio";

import { logger } from "@/logger";
import { ConfigService } from "@/config/config.service";
Expand Down Expand Up @@ -101,35 +101,36 @@ export class FileService implements OnModuleInit {
private readonly configService: ConfigService
) {
const config = this.configService.config.services.minio;
const commonOptions: Pick<ClientOptions, "accessKey" | "secretKey" | "region"> = {
accessKey: config.accessKey,
secretKey: config.secretKey,
region: "us-east-1"
};

this.minioClient = new MinioClient({
...parseMainEndpointUrl(config.default.endpoint),
accessKey: config.accessKey,
secretKey: config.secretKey
...commonOptions
});
this.bucket = config.bucket;
this.minioSigner = {
[MinioSignFor.UserUpload]: {
client: new MinioClient({
...parseMainEndpointUrl(config?.forUserUpload?.endpoint || config.default.endpoint),
accessKey: config.accessKey,
secretKey: config.secretKey
...commonOptions
}),
replaceUrl: parseSignEndpointUrl(config?.forUserUpload?.urlEndpoint || config.default.urlEndpoint)
},
[MinioSignFor.UserDownload]: {
client: new MinioClient({
...parseMainEndpointUrl(config?.forUserDownload?.endpoint || config.default.endpoint),
accessKey: config.accessKey,
secretKey: config.secretKey
...commonOptions
}),
replaceUrl: parseSignEndpointUrl(config?.forUserDownload?.urlEndpoint || config.default.urlEndpoint)
},
[MinioSignFor.Judge]: {
client: new MinioClient({
...parseMainEndpointUrl(config?.forJudge?.endpoint || config.default.endpoint),
accessKey: config.accessKey,
secretKey: config.secretKey
...commonOptions
}),
replaceUrl: parseSignEndpointUrl(config?.forJudge?.urlEndpoint || config.default.urlEndpoint)
}
Expand Down

0 comments on commit 04a0b28

Please sign in to comment.