node-zip
node-zip copied to clipboard
zip image from an url
Hello, How can I fetch the data of an image from facebook via an URL (I already got the URL) and zip the file to my local storage? Any suggestion would be very helpful.
Something like that:
var fs = require('fs');
var http = require('http-get'); // https://github.com/SaltwaterC/http-get
var zip = new require('node-zip')();
http.get({url: "your Facebook image's URL here"}, function (err, result){
if( err ) throw err;
zip.file('filename.ext', result.buffer);
fs.writeFileSync(
'localStorage.zip',
zip.generate({
base64: false,
compression: 'DEFLATE'
}),
'binary'
);
});
(The code was not tested. It's just a suggestion.)
This did not help... not working with the image files.... :(
how can we add an image file from project directory something like an image which has uploaded by user to our zip archive?
Can you provide the sample code that fails for you? in theory this problems have nothing to do with this module.