https://www.jianshu.com/p/e159c12e60fb
//参考 https://help.aliyun.com/document_detail/32077.html?spm=a2c4g.11186623.6.1220.1e4177a3nVKaEc
// https://blog.csdn.net/delebasou/article/details/85237941
// https://blog.csdn.net/qq_38523017/article/details/87712818
// https://blog.csdn.net/qq_38523017/article/details/87714246
// 获取私有url:https://blog.csdn.net/aku3927/article/details/95049165
// STS:https://blog.csdn.net/qq_31001061/article/details/123935411
//我根据这个做出来的,但是我的buket是私有的,需要使用STS签名,所以还需要加上'x-oss-security-token':securityToken securityToken是后台获取的,
https://blog.csdn.net/weixin_42112865/article/details/90414065
wx.uploadFile({
url: aliyunServerURL, //开发者服务器 url
filePath: filePath, //要上传文件资源的路径
name: 'file', //必须填file
formData: {
'key': aliyunFileKey,
'policy': policyBase64,
'OSSAccessKeyId': accessid,
'signature': signature,
'success_action_status': '200',
'x-oss-security-token': securityToken // 使用STS签名时必传(后台接口提供)
},
success: function(res) {
debugger
if (res.statusCode != 200) {
failc(new Error('上传错误:' + JSON.stringify(res)))
return;
}
successc(aliyunServerURL + aliyunFileKey);
},
fail: function(err) {
debugger
err.wxaddinfo = aliyunServerURL;
failc(err);
},
});
阿里云OSS,nodejs获取私有url
// npm i ali-oss
const OSS = require('ali-oss');
const client = new OSS({
accessKeyId: '你自己的key id',
accessKeySecret: '你自己的key secret',
bucket: 'bucket 名字',
endpoint: 'bucket所处的地址,例如:https://oss-cn-shenzhen.aliyuncs.com'
});
// 文件路径名称,过期时间"
let signUrl = client.signatureUrl('文件路径名称', {expires: 86400});
console.log(signUrl);
浙公网安备 33010602011771号