分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 软件开发

vue-cli(node)上传到OSS(阿里云)

发布时间:2023-09-10 07:27责任编辑:苏小强关键词:暂无标签

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);

vue-cli(node)上传到OSS(阿里云)

原文地址:https://www.cnblogs.com/dianzan/p/10677737.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved