Closed neegqi closed 7 years ago
@neegqi , please refer to #141 .
Thank u so much
@wkh237 i used the param "append=true" But it does not seem to work,I used the method progress() to listening progress,
@neegqi , I think the information in #141 is a little out of dated. Instead of using append=true
, you should add overwrite : true
to Fetch.config
. Please refer to the document. Thanks !
@wkh237
Here is my code
RNFetchBlob.config({
path: dirs + '/data.mp4?append=true',
overwrite: true
}).fetch('GET', 'http://apicloudspace.b0.upaiyun.com/apicloud-video/c1.1.mp4')
.progress((received, total) => {
console.log('progress', (received / total).toFixed(2)+"&&&&"+(total/(1024*1024)).toFixed(2))
})
.then((res) => {
// the temp file path with file extension `png`
console.log(res)
console.log('The file saved to ', res.path())
// Beware that when using a file path as Image source on Android,
// you must prepend "file://"" before the file path
})
Is there an something wrong in the code? was i ctl+r to reload , console Output the received Always begining from 0
@neegqi , if you set overwrite to true
, it exactly overwrites old data, I assume you should set it to false
and remove ?append=true
params.
Besides, you should handle HTTP Range Request yourself if you're going to implement somehting like resumable download.
Resolved , its worked . thank
s
fs.exists(dest) .then((ext) => { if (ext) { return fs.stat(dest) .then((stat) => stat) } else return Promise.resolve({ size: 0 }) }) .then((stat) => { console.log(stat) return RNFetchBlob .config({ path: dest, overwrite: false }) .fetch('GET', 'http://apicloudspace.b0.upaiyun.com/apicloud-video/c1.1.mp4', { Range:
bytes=${stat.size}- }) .progress((received, total) => { const ss = 1024 * 1024; console.log('progress', (received / total).toFixed(2) + "&&&&" + (total / ss).toFixed(2)) }) })
To download a large file if the network was disconnect,now i how to resume to download?