使用方式可以參考 demo
下載微信小程序開發工具
增加 demo 目錄為新項目
運行服務器進程
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 的服務器接口 getSignatureUrl 接受 GET 請求,帶有 policy 參數,返回 signature
signature 的計算公式是
md5(policy + '&' + secret)
其中,secret 是表單提交密鑰