拼接完整链接后再程序里面访问401,在浏览器访问正常
// qiniu saveas QN.prototype.saveas = function ( bucketname, key, saveBucketname, saveKey, param ) { const self = this; let url = this.getUrl(bucketname, key) + param; const entryUri = saveBucketname + ':' + saveKey; const encodedEntryURI = qiniu.util.urlsafeBase64Encode(entryUri); url += '|saveas/' + encodedEntryURI; const sign = qiniu.util .hmacSha1(url.replace('http://', ''), this._qiniu.conf.SECRET_KEY); const encodedSign = qiniu.util.base64ToUrlSafe(sign); url += '/sign/' + this._qiniu.conf.ACCESS_KEY + ':' + encodedSign; console.log(url); //这里请求401报错 return http.get(url, function () { console.log(arguments); }); };
报错信息:
error: "verify the sign failed"
想请教这是什么原因,是请求头的问题吗?
欢迎选择我的课程,让我们一起见证您的进步~~