1. 程式人生 > >阿里雲OSS之STS授權刪除檔案【JS版】

阿里雲OSS之STS授權刪除檔案【JS版】

$.post("<%=basePath%>app/GameController/uploadFile",function(response){

                                //這裡是從服務端拿下面這些引數

if(response.data.code == 0){
var client = new OSS({
       region: 'oss-cn-shenzhen',
       accessKeyId : response.data.data.accessKeyId,
       accessKeySecret : response.data.data.accessKeySecret,
       stsToken:response.data.data.securityToken,
       bucket : 'youbucket'
       });
OSS.co(function* () {
//單個檔案刪除
    //var result = yield client.delete('img/apk_image/20180622121416.jpg');
    //批量檔案刪除
var result = yield client.deleteMulti(["img/apk_image/20180620145148.jpg","img/apk_image/20180620145850.jpg",])
/* var result = yield client.deleteMulti(['img/apk_image/20180620183458.jpg', 'img/apk_image/20180620181507.jpg'], {
    quiet: true
  }); */
    console.log(result);
  }).catch(function (err) {
    console.log(err);
  });
}else{

}
},"json");