收藏
回答

cloud.uploadFile ArrayBuffer 报错

问题模块 框架类型 问题类型 终端类型 AppID 基础库版本
云开发 小程序 Bug 工具 wxf621ea0f45cd64d3 2.7.5

- 当前 Bug 的表现(可附上截图)


- 预期表现


- 复现路径


- 提供一个最简复现 Demo

//小程序

async submitImages() {
 
    let pageData = this.data;
 
    let fm = wx.getFileSystemManager();
 
    await this.data.cover_url_list.forEach(item => {
 
        fm.readFile({

            filePath: item,

           //返回 ArrayBuffer

            // encoding: "base64",
            success: res => {
                // console.log("imgbase64:"+res.data)
                    wx.cloud.callFunction({
                        // 云函数名称
                        name: 'upload_album',
                        // 传给云函数的参数
                        data: {
                            imageArrayBuffer: res.data
                        },
                        success: res => {
                            console.log(res);
                        },
                        fail: res => {
                            console.log(res);
                        },
                        complete: res => {
                            // console.log('callFunction test result: ', res)
                        },
                    })
                
            }
        })
    })
},




//云函数

// 云函数入口函数
exports.main = async(event, context) => {
 
    return await cloud.uploadFile({
        cloudPath: 'demo.jpg',
        fileContent: event.imageArrayBuffer.data,
    })
}


最后一次编辑于  07-18  (未经腾讯允许,不得转载)
回答关注问题邀请回答
收藏

1 个回答

  • 邓坤力
    邓坤力
    07-21

    在云函数中需先转换回 buffer

    07-21
    赞同
    回复