我在数据库和云存储中放入了张图片,但是在获取下载链接的时候获取不到,报错"storage_sign_param_invalid"的错误。
{"errcode":0,"errmsg":"ok","file_list":[{"fileid":"cloud://dev-7q032.6465-dev-1300969255/swiper/1583332218903.jpg","download_url":"","status":1,"errmsg":"STORAGE_SIGN_PARAM_INVALID"}]}
下面是我的demo代码:
let ACCESS_TOKEN =await getAccessToken();
const DownloadURL = `https://api.weixin.qq.com/tcb/batchdownloadfile?access_token=${ACCESS_TOKEN}`;
let fileList=[{
fileid:'cloud://dev-7q032.6465-dev-7q032-1300969255/swiper/1583332218903.jpg',
max_age:7200
}]
let options= {
method: 'POST',
url:DownloadURL,
body: {
"env": ENV,
"file_list":fileList
},
json:true
}
return await rp(options)
.then(res=>{
console.log('批量下载地址'+JSON.stringify(res))
return res
})
请大佬告知是哪里问题
你是用 http api上传的图片,然后再下载的吗
let params = {
method: 'POST',
headers:{
'content-type':'multipart/form-data'
},
uri:response.url,
formData:{
key:path,
Signature:response.authorization,
"x-cos-security-token":response.token,
"x-cos-meta-fileid":response.file_id,
file:fs.createReadStream(file.path)
}
}
await rp(params)
.then(response=>{
console.log('上传的response'+JSON.stringify(response));
})