I'm trying to download a group of image files that I am retrieving from Parse and save them to a zip file using JSZip. From this link it seems like I should be able to get the base64 encoding just by calling .base64 on my image object. I also tried toString('base64'). My zip file generates with files of the correct names but the contents of the files are empty. Am I missing something here?
Parse.Cloud.httpRequest({ url: result.get('image').url() }).then(function(response) {
var image = new Image();
image.setData(response.buffer);
var base64Image = image.data().base64;
zip.folder('images').file(imageName, base64Image, {base64: true});
return Parse.Promise.as('Success')
})
Finally managed to solve it by treating image.data() as asynchronous:
Parse.Cloud.httpRequest({ url: result.get('image').url() }).then(function(response) {
var image = new Image();
image.setData(response.buffer);
return image.data().then(function(data) {
zip.folder('images').file(imageName, data.toString('base64'), {base64: true});
return Parse.Promise.as('Success');
});
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.