oak-external-sdk/lib/S3SDK.js

24 lines
824 B
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.S3Instance = void 0;
const S3_1 = require("./service/s3/S3");
Object.defineProperty(exports, "S3Instance", { enumerable: true, get: function () { return S3_1.S3Instance; } });
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 S3_1.S3Instance(accessKey, accessSecret, endpoint, region);
this.s3Map[key] = instance;
return instance;
}
}
const SDK = new S3SDK();
exports.default = SDK;