收藏
回答

求助:为什么调用cloud.downloadFile总是失败?

代码如下:

// 云函数入口函数

exports.main = async (event, context) => {

  console.log("event = ", event)

  let {

    param1

  } = event

  console.log("0000000000000=", param1)

  //1,通过fileID下载云存储里的excel文件

  const res = await cloud.downloadFile({

    fileID: param1,

  })

......

}


错误如下:

[info] 函数被触发,正在执行中...

index.js:13 event =  {param1: "cloud://ztzgr-pms-c-fq4yo.7a74-ztzgr-pms-c-fq4yo-1301995773/HRCost.xls"}param1: "cloud://ztzgr-pms-c-fq4yo.7a74-ztzgr-pms-c-fq4yo-1301995773/HRCost.xls"__proto__: Object

index.js:17 0000000000000= cloud://ztzgr-pms-c-fq4yo.7a74-ztzgr-pms-c-fq4yo-1301995773/HRCost.xls

node.js:1 [error] 函数执行失败(耗时 257ms) Error: errCode: -1 unknown error | errMsg: downloadFile:fail TypeError: Cannot read property '0' of undefined; at downloadFile api

    at returnAsCloudSDKError (E:\0.GIT\ProjectManager\微信项目费用管理\cloudfunctions\excel\node_modules\wx-server-sdk\index.js:6027:16)

    at Object.returnAsFinalCloudSDKError (E:\0.GIT\ProjectManager\微信项目费用管理\cloudfunctions\excel\node_modules\wx-server-sdk\index.js:6041:15)

    at E:\0.GIT\ProjectManager\微信项目费用管理\cloudfunctions\excel\node_modules\wx-server-sdk\index.js:2419:39

    at processTicksAndRejections (internal/process/task_queues.js:85:5)

_ @ node.js:1

u @ node.js:1

processTicksAndRejections @ internal/process/task_queues.js:85

Promise.catch (async)

(anonymous) @ node.js:1

emit @ events.js:208

endReadableNT @ _stream_readable.js:1154

processTicksAndRejections @ internal/process/task_queues.js:77

TickObject (async)

init @ internal/inspector_async_hook.js:21

emitInitNative @ internal/async_hooks.js:134

emitInitScript @ internal/async_hooks.js:341

TickObject @ internal/process/task_queues.js:102

nextTick @ internal/process/task_queues.js:130

endReadable @ _stream_readable.js:1143

Readable.read @ _stream_readable.js:425

flow @ _stream_readable.js:977

emitReadable_ @ _stream_readable.js:572

onEofChunk @ _stream_readable.js:536

readableAddChunk @ _stream_readable.js:243

Readable.push @ _stream_readable.js:210

parserOnMessageComplete @ _http_common.js:150

HTTPINCOMINGMESSAGE (async)

init @ internal/inspector_async_hook.js:21

emitInitNative @ internal/async_hooks.js:134

connectionListenerInternal @ _http_server.js:366

defaultTriggerAsyncIdScope @ internal/async_hooks.js:301

connectionListener @ _http_server.js:339

emit @ events.js:203

onconnection @ net.js:1473

node.js:1 [info] 调用 本地 云函数 'excel' 完成  (耗时 284ms)

回答关注问题邀请回答
收藏

3 个回答

  • 卢索
    卢索
    2022-11-27

    可能是初始化的云环境id错误

    2022-11-27
    有用
    回复
  • 大熊
    大熊
    2022-01-12

    我也是遇到这问题,你解决了吗

    2022-01-12
    有用
    回复
  • Cheshire cat
    Cheshire cat
    2020-05-09

    试下getTempFileUrl这个接口获取临时连接是否正常呢

    2020-05-09
    有用
    回复
登录 后发表内容
问题标签