初始化

使用SDK功能前,需要新建Client,代码如下:

let S3Demo = {
    credentials: {
        accessKeyId: "<your-access-key>",
        secretAccessKey: "<your-secret-key>",
    },
    s3Client: null,

    init: function() {
        let config = {
            credentials: this.credentials,
            endpoint: "<your-endpoint>",  // e.g. http://endpoint or https://endpoint
            //signatureVersion: 'v4', // 预签名使用v4版本签名,默认为v2
            //httpOptions: { timeout: 120000 }, // 设置请求超时,default 120000,单位毫秒
        };
        this.s3Client = new AWS.S3(config);
    },
}
参数 说明
credentials 用户账号信息,包含accessKeyId和secretAccessKey
endpoint 天翼云资源池的地址,必须指定http或https前缀