- 下载遇到parameter.path should be String
- 当前 Bug 的表现(可附上截图) 使用 wx.downloadFile() 函数,传入 filePath 参数的时候会报 stat:fail parameter error: parameter.path should be String instead of Undefined; 的错误。 filePath 的值是 window.wx.env.USER_DATA_PATH + "/" + "相对路径" - 预期表现 - 复现路径 - 提供一个最简复现 Demo
2019-05-11 - 云函数下载文件保存到临时文件再读取的时候报错,为什么?
[代码]const cloud = require([代码][代码]'wx-server-sdk'[代码][代码])[代码][代码]const request = require([代码][代码]'request'[代码][代码])[代码][代码]const fs = require([代码][代码]'fs'[代码][代码])[代码][代码]const path = require([代码][代码]'path'[代码][代码])[代码] [代码]return[代码] [代码]new[代码] [代码]Promise([代码][代码]function[代码] [代码](resolve, reject) {[代码][代码] [代码][代码]request(options, (error, response, body) => {[代码][代码] [代码][代码]let jsonBody = JSON.parse(body)[代码][代码] [代码][代码]downUrl = jsonBody.download_url[代码][代码] [代码][代码]let p = path.join(__dirname, [代码][代码]'/tmp/file.mp4'[代码][代码])[代码][代码] [代码][代码]request(downUrl).pipe(fs.createWriteStream(p)).on([代码][代码]'close'[代码][代码], () => {[代码][代码] [代码][代码]const fileStream = fs.createReadStream(p)[代码][代码] [代码][代码]resolve(cloud.uploadFile({[代码][代码] [代码][代码]cloudPath: [代码][代码]'file.mp4'[代码][代码],[代码][代码] [代码][代码]fileContent: fileStream,[代码][代码] [代码][代码]})[代码][代码] [代码][代码])[代码] [代码] [代码][代码]})[代码][代码] [代码][代码]})[代码][代码] [代码][代码]})[代码] ##报错日志 2019-08-10T03:38:05.684Z { Error: ENOENT: no such file or directory, open '/var/user/tmp/file.mp4' errno: -2, code: 'ENOENT', syscall: 'open', path: '/var/user/tmp/file.mp4' } END RequestId: 430c6bf0-bb20-11e9-9e13-5254007aa7a1 Report RequestId: 430c6bf0-bb20-11e9-9e13-5254007aa7a1 Duration:797ms Memory:256MB MaxMemoryUsed:3.015625MB
2019-08-10