fix endpoint

This commit is contained in:
fyears 2021-11-14 21:12:31 +08:00
parent 59645e620a
commit 714807cdc7

View File

@ -45,9 +45,13 @@ export const DEFAULT_S3_CONFIG = {
export type S3ObjectType = _Object; export type S3ObjectType = _Object;
export const getS3Client = (s3Config: S3Config) => { export const getS3Client = (s3Config: S3Config) => {
let endpoint = s3Config.s3Endpoint;
if (!(endpoint.startsWith("http://") || endpoint.startsWith("https://"))) {
endpoint = `https://${endpoint}`;
}
const s3Client = new S3Client({ const s3Client = new S3Client({
region: s3Config.s3Region, region: s3Config.s3Region,
endpoint: s3Config.s3Endpoint, endpoint: endpoint,
credentials: { credentials: {
accessKeyId: s3Config.s3AccessKeyID, accessKeyId: s3Config.s3AccessKeyID,
secretAccessKey: s3Config.s3SecretAccessKey, secretAccessKey: s3Config.s3SecretAccessKey,