EvanOxfeld / node-unzip

node.js cross-platform unzip using streams
MIT License
615 stars 343 forks source link

unzip issue Error: invalid signature: 0xe0ffd8ff #93

Open Rahul-Jagga opened 8 years ago

Rahul-Jagga commented 8 years ago

The problem is when i upload docs,ppt,pdf files its working fine but when i upload jpg , png files it generates the Error: invalid signature: 0xe0ffd8ff. If there is anybody to help use then contact us and help as soon as thanks advance. parse

this is my index.js file where i put my function for file conversion : // callback for upload files app.post("/upload",function(req,res){ console.log("file name="+file_name); console.log(req.body); fs.createReadStream(file_path).pipe(cloudconvert.convert({ inputformat: filename.split('.').pop(), outputformat: 'jpg', /* converteroptions: { quality : 75, }/ }).on('error', function(err) { console.error('Failed: ' + err); //alert('Failed:'+err +'please refresh....'); }).on('finished', function(data) { console.log('Done: ' + data.message); //alert('Done:' + data.message + 'continue....'); this.pipe(fs.createWriteStream('public/upload/'+file_name.split('.').shift()+'.zip')); }).on('downloaded', function(destination) { console.log('Downloaded to: ' + destination.path); fs.mkdirSync('public/upload/'+file_name.split(".").shift()); var read=fs.createReadStream(destination.path); console.log('read directory to: ' + read); read.pipe(unzip.Extract({ path: 'public/upload/'+file_name.split(".").shift()+'/' })); console.log(file_name.split(".").shift()); read.on('end',function(){ fs.readdir('public/upload/'+filename.split(".").shift()+'/', function(err, files) {
//
*****DSC Error console.log("lenght"+files.length) if(!err){ for(var i=0;i<files.length;i++){ files[i]='upload/'+file_name.split('.').shift()+'/'+files[i]; console.log(files[i]); } res.send({'slides':files}); res.end(); } }); }); }));

    res.setTimeout(120000*10, function(){
        console.log('Request has timed out.');
            res.send({'status':408});
            res.end();
        });

});

mhr3 commented 7 years ago

If you're still having this issue, I've published unzip-stream which should solve it.