The case :
Can i use same instance of s3 client but alter the credentials based on the requesting user credentials?
Like this :
class S3Storage {
private readonly s3: AWS.S3;
constructor(config: S3Config) {
this.s3 = new AWS.S3({
accessKeyId: config.accessKeyId,
secretAccessKey: config.secretAccessKey,
apiVersion: config.apiVersion,
region: config.region
});
}
public myDownload (key: string, userData: any) {
// alter credentials for this.s3 with the userData
}
}
Or should i create s3 client (with provided userData) every time myDownload
function is invoked.
我最终为每个请求创建了 S3 客户端,而不是缓存已经缓存的对象,因为在每个请求中,系统都会获得一个临时生成的凭据。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.