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

File upload functionality breaks when dealing with larger size files #75

Open
shubhit7 opened this issue May 14, 2023 · 0 comments
Open

Comments

@shubhit7
Copy link

Large File Upload Fails

Describe the bug
File upload of larger file size, say >2GB, fails after sometime.

To Reproduce
Steps to reproduce the behavior:
Try to upload a file of size >2GB, upload process starts but crashes after some time.

Expected behavior
File should be uploaded successfully.

Additional context
IMHO, the file should be uploaded in chunks.

slice_file(file) {
var offset = 0;
var next_offset;
var chunks = [];
this.num_chunks = Math.ceil(file.size / this.chunk_size);
for (let i = 0; i < this.num_chunks; i++) {
next_offset = Math.min(this.chunk_size * (i + 1), file.size);
chunks.push(file.slice(offset, next_offset));
offset = next_offset;
}
return chunks;
}

This code splits the files in chunks but stores all the chunks in an array, which is ultimately present in the memory.
Hence, when dealing with larger file size, this code may crash.
I would suggest, to read to file in chunks rather than storing chunks of whole file in array.

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

1 participant