daraosn / node-zip

217 stars 38 forks source link

zip image from an url #7

Open sweetguy0883 opened 10 years ago

sweetguy0883 commented 10 years ago

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.

Mithgol commented 10 years ago

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

sweetguy0883 commented 10 years ago

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

arycloud commented 8 years ago

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

trufae commented 8 years ago

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