oak-external-sdk/es/S3SDK.js

21 lines
624 B
JavaScript

import { S3Instance } from './service/s3/S3';
class S3SDK {
s3Map;
constructor() {
this.s3Map = {};
}
getInstance(accessKey, accessSecret, endpoint, region = 'us-east-1') {
// 使用 accessKey + endpoint 作为唯一标识
const key = endpoint ? `${accessKey}:${endpoint}` : accessKey;
if (this.s3Map[key]) {
return this.s3Map[key];
}
const instance = new S3Instance(accessKey, accessSecret, endpoint, region);
this.s3Map[key] = instance;
return instance;
}
}
const SDK = new S3SDK();
export default SDK;
export { S3Instance };