Closed
Description
Description
I'm using RN=0.42 and trying to implement a progress-bar for a video upload. We're uploading using XHR, setting Content-Length and Content-Type, and seeing "progress" events fire, but the params sent to the event handler carry no information about progress (i.e. lengthComputable or something about bytes sent).
Our code is essentially this:
const upload = (uri) => {
return new Promise((resolve, reject) => {
const formdata = new FormData()
formdata.append('file', {uri: `file://${uri}`, type: 'video/mp4', name: 'upload.mp4'})
let xhr = new XMLHttpRequest()
xhr.open('POST', upload_url)
xhr.setRequestHeader('Content-Length', 10000)
xhr.setRequestHeader('Content-Type', 'multipart/form-data')
xhr.onload = resolve
xhr.onerror = reject
xhr.upload.addEventListener('progress', (e,a,b,c,d) => console.log('progress', e,a,b,c,d))
xhr.send(formdata)
})
})
Reproduction
See above
Solution
Hopefully someone can point out a parameter (HTTP header?) I'm missing, or perhaps there's a bug in the RN xhr implementation.
Additional Information
- React Native version: 0.42
- Platform: iOS
- Operating System: Mac
- Dev tools: Atom