使用方式可以參考 demo
下載微信小程序開發(fā)工具
增加 demo 目錄為新項(xiàng)目

運(yùn)行服務(wù)器進(jìn)程
npm run demo
Upyun
示例
const upyun = new Upyun({
bucket: 'sdkimg',
operator: 'tester',
getSignatureUrl: 'http://localhost:8080',
})
Upyun.prototype.upload
upyun.upload({
localPath: imageSrc,
remotePath: '/wxapp/demo',
success: function(res) {
},
fail: function({errMsg}) {
},
})
計算 signature 的服務(wù)器接口 getSignatureUrl 接受 GET 請求,帶有 policy 參數(shù),返回 signature
signature 的計算公式是
md5(policy + '&' + secret)
其中,secret 是表單提交密鑰