Giter Site home page Giter Site logo

Comments (12)

ctalkington avatar ctalkington commented on June 6, 2024

going to need a code sample and environment information. there are tests for such things which all currently pass.

from node-archiver.

cevek avatar cevek commented on June 6, 2024

os x 10.9. Just try append some empty files to tar archive.

On 9 November 2013 03:31, Chris Talkington [email protected] wrote:

going to need a code sample and environment information. there are tests
for such things which all currently pass.


Reply to this email directly or view it on GitHubhttps://github.com//issues/49#issuecomment-28106912
.

from node-archiver.

ctalkington avatar ctalkington commented on June 6, 2024

sorry, i don't have a mac to test on.

what version of node? archiver? how are you adding the file (stream or buffer)? if stream, what kind legacy or stream2?

from node-archiver.

sethkinast avatar sethkinast commented on June 6, 2024

I'll be more helpful than that guy!

Mac OS X 10.7
Node 10.22
Archiver 0.5.0-alpha

var archive = archiver('tar');
archive.pipe(res); // I'm in Express
archive.append(fs.createReadStream(path.resolve("path", "to", "emptyFile.txt")), { name: "empty.txt" });

res.set('Content-Disposition', 'attachment; filename=empty.txt');
archive.finalize();

Fails silently without throwing an error (the finalize() callback is never invoked, and archive.on('error') is not invoked either.

from node-archiver.

ctalkington avatar ctalkington commented on June 6, 2024

wouldn't you set content-disp before pipe? as it could be sending data before you define what it is?

from node-archiver.

ctalkington avatar ctalkington commented on June 6, 2024

hum, i think the test has multiple appends, maybe the first one kick starts the thing and single doesn't. will have to play with it next time im editing things.

from node-archiver.

sethkinast avatar sethkinast commented on June 6, 2024

I had assumed that nothing was actually sent until finalize() was called, since it seemed to work fine. I moved the Content-Disposition setter but it had no effect on the output, it seems.

My actual code does do multiple appends, which doesn't work either, unfortunately. The empty file is the last file appended-- I tried changing the order so that the empty file came first, and that didn't change anything.

The actual code in my app:

files.forEach(function(f) {
    archive.append(fs.createReadStream(path.resolve(CONTENT_DIR, f)), { name: f });
});

from node-archiver.

sethkinast avatar sethkinast commented on June 6, 2024

Unrelated: this is the best, easiest node package for tarring and zipping out there, thanks :)

from node-archiver.

ctalkington avatar ctalkington commented on June 6, 2024

you could actually use file now too with latest alpha. let it handle the stream creating for you.

from node-archiver.

ctalkington avatar ctalkington commented on June 6, 2024

glad you like the package. v0.5 is going to really redefine the internals of it all with tar and zip logic being switched to modules internally. zip-stream and tar-stream will be integrated in the coming weeks which should allow for quick targeted fixes to output related issues without need to update archiver itself.

from node-archiver.

sethkinast avatar sethkinast commented on June 6, 2024

So using .file() actually works, and the zero-byte file is included correctly!

from node-archiver.

ctalkington avatar ctalkington commented on June 6, 2024

ah so my guess is that stream emits before archiver can handle it.

from node-archiver.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.