Skip to content

StreamSaver enables you to stream large files directly to the file system

License

Notifications You must be signed in to change notification settings

K1Z4/StreamSaver.js

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

StreamSaver.js

StreamSaver allows you to stream files directly to the filesystem. This allows you to save large files which you normally would not be able to due to max Blob size, RAM or browser restrictions.

Differences from Jimmy Wärting's StreamSaver

Jimmy Wärting's original version of StreamSaver supports streaming files on non-secure webpages, this means there is quite a lot of additional complexity to enable that to happen. This fork of StreamSaver drops support for non-secure webpages and streamlines the library. The result is a library which does not require the use of iframes or popups.

How does it work

A service worker is created which handles requests to the configured scope e.g. /downloads. We then fulfill the request with a ReadableStream.

Examples

Check out the examples folder for a working example.

//Check support
const supported = StreamSaver.supported;

// All params optional
const streamSaver = new StreamSaver({ scope: "src/downloads", serviceWorkerPath: "src/StreamSaverServiceWorker.js" });
const stream = streamSaver.createStream({ name: "helloWorld.txt", size: 100, contentType: "application/text"  });
const writer = stream.getWriter();

writer.write(uint8array);
// or
writer.write(arrayBuffer);
writer.close();

Browser Support

Browser Supported Missing
Opera 39+ Yes
Chrome 52+ Yes
Firefox No Streams
Safari     No       Service Worker
Edge No Streams, Service Worker
IE No Everything (IE is dead)

About

StreamSaver enables you to stream large files directly to the file system

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 77.6%
  • HTML 22.4%