AV.File not saving base64
johncalvinroberts opened this issue Β· comments
Hi all, having an issue with the leanengine sdk AV.File.save api in node v8.9.1. The URL in the response shows a blank image, and base64 seems to have not been saved to the database.
I'm getting an image's binary png from another restful endpoint, and want to save it as an instance of AV.File. Like so:
function ({data}) {
const base64data = new Buffer(data.toString(), 'binary').toString('base64')
const file = new AV.File(`qr_code.png`, {base64: base64data}, 'image/png')
return file.save()
}
The response from saving to the backend looks like this:
{ "result": { "name": "qr_1.png", "url": "http://ac-tSaB7MBC.clouddn.com/9a12355a3edee6f7af17.png", "metaData": { "owner": "unknown" }, "base64": "", "mime_type": "image/png", "objectId": "5a9d0ffbfe88c21c80c6d5b2" } }
The URL shows a blank image, also base64 in the response is blank. I've done the same thing with base64 in the frontend with leancloud-storage package and had no problem. Thanks in advance!! And thanks for an awesome product in general~~~
Can you please provide a base64data
for me to reproduce this issue?
Also, in Node.js, AV.File
accepts a Buffer or a Stream as the data
param. So there is no need to encode the data to base64 string.
@leeyeh Thanks for your response. I tried sending just the buffer as well, also no luck. This is the binary I'm working with, data namespace from this endpoint:
EDIT: Sorry, left out some details. POST to this ^^ url, with this body:
{ "path": "/pages/animal-profile?animal=5a9ba96afe88c21c80bf62f4" }
EDIT2: Changed access token, it expired
We have a tested sample(w/ axios) for such use case: https://forum.leancloud.cn/t/topic/14469/4?u=leeyeh
And a request version: https://forum.leancloud.cn/t/topic/14469/18?u=leeyeh
Ah I see, have to specify response type. It works now πππ
Thanks! π
Glad to help. π