node-sdk
node-sdk copied to clipboard
uploadFile fileContent无法使用 Base64转换后的Buffer,上传到云存储的图片损坏
这个是转换的代码
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)
请教是哪里姿势不正确
1
可以提供完整的demo么,我这边复现看下问题