Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Can this library work with Web Streams ? #759

Open
AlwaysNoobCoder opened this issue Apr 25, 2024 · 1 comment
Open

[Question] Can this library work with Web Streams ? #759

AlwaysNoobCoder opened this issue Apr 25, 2024 · 1 comment

Comments

@AlwaysNoobCoder
Copy link

Such as FileSystemWritableFileStream

@mrclay
Copy link

mrclay commented Nov 21, 2024

@AlwaysNoobCoder I'm using something like this in a NextJS app route:

  const archive = archiver('zip');

  const webStream = new ReadableStream({
    start(controller) {
      archive.on('data', chunk => controller.enqueue(chunk));
      archive.on('end', () => controller.close());
      archive.on('error', err => controller.error(err));

      archive.append(...);
      archive.append(...);
      archive.finalize();
    },
  });

  return new Response(webStream, {
    headers: {
      'Content-type': 'application/zip',
      'Content-Disposition': 'attachment;filename=archive.zip',
    },
  });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants