Closed FloatingMind12 closed 1 year ago
Nope.
You could only do this with the native file system access which is only available in Blink
Too bad. In that case, is it possible to copy a WritableStream's already writen data to a new one? Or would that need file system access as well?
Uhm, you can't exactly copy a file after it have been writen. StreamSaver.js don't have any access what so ever to the disk. it acts more or less how a regular file is downloaded from a server. 1) You click on a link. 2) the thing can't be rendered, so it fallbacks to saving the response on the disk.
file name is adjusted with content-disposition attachment response header.
You could tee
the stream and write it to two destinations.
but you would have to create two downloads for it.
const dest1 = streamSaver.createWriteStream('a.txt')
const dest2 = streamSaver.createWriteStream('b.txt')
// Get a readable stream somehow, somewhere
const readable = new Response('foobar').body
// clone the stream
const [readable1, readable2] = readable.tee()
readable1.pipeTo(dest1)
readable2.pipeTo(dest2)
Thank you for the answer but that would defeat the purpose of renaming the stream. The only way left I can think of then is to create some kind of server apps that would have access to local files and make it communicate with the script running on the browser.
Is there a way to rename a WritableStream after it has already been created and has data writen into?