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

zip image from an url

Open sweetguy0883 opened this issue 11 years ago • 4 comments

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.

sweetguy0883 avatar Jan 27 '14 13:01 sweetguy0883

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.)

Mithgol avatar Jan 27 '14 16:01 Mithgol

This did not help... not working with the image files.... :(

sweetguy0883 avatar Jan 28 '14 11:01 sweetguy0883

how can we add an image file from project directory something like an image which has uploaded by user to our zip archive?

arycloud avatar Apr 16 '16 09:04 arycloud

Can you provide the sample code that fails for you? in theory this problems have nothing to do with this module.

trufae avatar Sep 13 '16 21:09 trufae