node-sdk icon indicating copy to clipboard operation
node-sdk copied to clipboard

uploadFile fileContent无法使用 Base64转换后的Buffer,上传到云存储的图片损坏

Open qhhsy opened this issue 5 years ago • 2 comments

这个是转换的代码

       const { fileID } = await app.uploadFile({
            cloudPath: 'aa8a.jpg',
            fileContent: Buffer.from(JSON.parse(event.body).file, 'base64'),
        })

下面是验证上传的base64是否有效的代码。将base64返回给前端可以正常显示

       context.isBase64Encoded= true;
        context.statusCode= 200;
        context.setHeader(
            'content-type','image/png'
        );
        const { fileID } = await app.uploadFile({
            cloudPath: 'aa8a.jpg',
            fileContent: Buffer.from(JSON.parse(event.body).file, 'base64'),
        })
        return context.end(JSON.parse(event.body).file)

请教是哪里姿势不正确

qhhsy avatar Jun 18 '20 03:06 qhhsy

1

qhhsy avatar Jun 22 '20 03:06 qhhsy

可以提供完整的demo么,我这边复现看下问题

Mrjing avatar Nov 03 '20 12:11 Mrjing