vue-cli 上傳圖片上傳到OSS(阿里雲)


https://help.aliyun.com/document_detail/32068.html?spm=5176.doc32069.6.304.Qc4SUs(看)

https://help.aliyun.com/document_detail/64095.html?spm=a2c4g.11186623.6.773.kcD20n(看)

https://github.com/ali-sdk/ali-oss?spm=a2c4g.11186623.2.12.23a710d5Q5CD1b(git)

 

'https://'+ bucket+ region+'.aliyuncs.com'+imgUrl
 
let client = new OSS({
region: "區域",
accessKeyId: "",
accessKeySecret: "",
bucket: "項目段"
});
 
//在函數中執行
let timestamp = Date.parse(new Date());
let string_4 = "";
for (let i = 0; i < 4; i++) {
string_4 += Math.floor(Math.random() * 9 + 1);
}
let imgUrl = "product-res/" + timestamp + string_4;
console.log(imgUrl);
console.log(headerUrl + "/" + imgUrl);
var file = obj.target.files[0]; //獲取文件流
client
.multipartUpload(imgUrl, file)
.then(function(result) {
console.log(result);
})
.catch(function(err) {
console.log(err);
});
console.log(client);


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM