Skip to content Skip to sidebar Skip to footer

Is It Possible To Dynamically Produce Large Files (10gb) And Stream Them To The Client?

Is it possible to dynamically produce large files (10Gb+) for the client to download? I'm building a webapp that dynamically creates files and downloads them to the client. I've im

Solution 1:

for < 800MB i would recommend FileSaver but for 10GB+ you are going to need something like StreamSaver (It will only work in Blink doe) 16GB+ haven't been any problem for me

const fileStream = streamSaver.createWriteStream('filename.txt')
const writer = fileStream.getWriter()
const encoder = new TextEncoder()

// When you have any data you write it as Uint8arraylet data = 'a'.repeat(1024)
let uint8array = encoder.encode(data + "\n\n")

writer.write(uint8array) // chunk
writer.write(uint8array) // chunk
writer.write(uint8array) // chunk
writer.write(uint8array) // chunk// After you have written all bytes you need to close it
writer.close()

(just don't write all chunks at once, do it progressively as you get more data avalible)

Post a Comment for "Is It Possible To Dynamically Produce Large Files (10gb) And Stream Them To The Client?"