Uploading an array of blobs with javascript and handling them on Node.js -


i trying workaround cloudflare's 100mb upload limit, sending chunked uploads. cannot seem figure out how start sending chunked data. have 100 blobs i'd send server, stream them? how server tell continuous requests relate each other?

here's code far:

getchunks(file) {   const divideby = 1 * 1024 * 1024   const availabledivisions = math.ceil(file.size / divideby)   let currentslice = 0    const chunks = array(availabledivisions)     .fill()     .map((iteration, index) => {       const nextdivision = divideby * (index + 1)       const chunk = file.slice(currentslice, nextdivision, file.type)        currentslice = nextdivision        return chunk     })    return chunks }  sendchunk(blob) {   return new promise((resolve, reject) => {     const xhr = new xmlhttprequest()      xhr.open('post', 'http://localhost:4080/test', true)     xhr.setrequestheader('content-type', blob.type)      xhr.onreadystatechange = () => {       if (xhr.readystate == xmlhttprequest.done && xhr.status == 200) {         resolve()       }     }      xhr.send(blob)   }) }  uploadchunked(file) {   const chunks = this.getchunks(file)    let iteration = 0    const upload = chunk => {     let nextiteration = iteration + 1     let nextchunk = chunks[nextiteration]      this.sendchunk(chunk).then(() => {       if (nextchunk) {         iteration = nextiteration         upload(nextchunk)       }     })   }    upload(chunks[0]) } 

so works fine, upload requests done correctly. problem figuring out how server should tell these consecutive requests refer 1 file. i've looked online , extremely confused @ part.

i've solved issue using tus protocol. server can accept chunked (and resumable) uploads, , cloudflare doesn't complain.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -