Last active
December 26, 2021 10:43
-
-
Save arunjayakumar01/91eacad08d4809bc8f4ea0ac68667eb9 to your computer and use it in GitHub Desktop.
Spit file into blobs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const file = document.getElementById('upload').files[0]; | |
const CHUNK_SIZE = 10000000; // 10MB | |
const fileSize = file.size; | |
const CHUNKS_COUNT = Math.floor(fileSize / CHUNK_SIZE) + 1; | |
let start, end, blob; | |
for (let index = 1; index < CHUNKS_COUNT + 1; index++) | |
{ | |
start = (index - 1) * CHUNK_SIZE; | |
end = (index) * CHUNK_SIZE; | |
blob = (index < CHUNKS_COUNT) ? file.slice(start, end) : file.slice(start); | |
// get blob and send the data to the upload functions | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment