初始化SDK
更新時間 2025-09-28 10:58:19
最近更新時間: 2025-09-28 10:58:19
分享文章
使用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. //endpoint or //endpoint
//signatureVersion: 'v4', // 預簽名使用v4版本簽名,默認為v2
//httpOptions: { timeout: 120000 }, // 設置請求超時,default 120000,單位毫秒
};
this.s3Client = new AWS.S3(config);
},
}參數說明:
| 參數 | 說明 |
|---|---|
| credentials | 用戶賬號信息,包含accessKeyId和secretAccessKey |
| endpoint | 天翼云資源池的地址,必須指定http或https前綴 |