cloud.downloadFile 云函数生产环境调用无反应?
现象:本地环境调试,可以获取图片资源的buffer。上传到正式环境,获取不到数据,且无异常信息。云函数设置超时时间都是20s;
相关代码:
// 传入一个小程序云存储的path,返回图片对应的资源id
const getImgMediaId = async function (imgPath) {
// 下载图片
const fileID = `${cloudFilePrefix}${imgPath}`
let finalRes = {}
let downFileRes = {}
console.log("fileID", fileID)
try {
downFileRes = await cloud.downloadFile({
fileID: fileID
})
console.log("downFileRes", downFileRes)
} catch (e) {
console.log(111, e)
}
try {
// 上传图片
finalRes = await cloud.openapi.customerServiceMessage.uploadTempMedia({
type: 'image',
media: {
contentType: 'image/jpeg',
value: file
}
})
} catch (e) {
console.log(222, e)
}
return finalRes
}
云函数日志:
返回结果
null
日志
START RequestId: f9903ccb-78b0-11ea-993b-525400090c2c
Event RequestId: f9903ccb-78b0-11ea-993b-525400090c2c
2020-04-07T09:20:09.668Z fileID cloud://xxxxxx/server/serviceTeacherErcode/tearcher_code_1.jpg
END RequestId: f9903ccb-78b0-11ea-993b-525400090c2c
Report RequestId: f9903ccb-78b0-11ea-993b-525400090c2c Duration:103ms Memory:256MB MemUsage:35.730469MB