Hello guys, Please help me regarding this. I am using this library to upload video to server. but in iOS getting this error in
onFetchBlobError: (e) => console.log(e),
Blob error = Error: File does not exist at path file:///....VIDEO_0010.mp4
at RNFetchBlobReadStream.js:47
I am doing this in my code:
const chunk = new ChunkUpload({
path: state.videoPath, // Path to the file
size: 4000, // Chunk size (must be multiples of 3)
fileName: state.videoFileName, // Original file name
fileSize: state.videoSize, // Original file size
onFetchBlobError: (e) => { console.log("Blob error = ", e) },
onWriteFileError: (e) => console.log("FileWrite error= ", e),
});
const upload = (file, next, retry, unlink) => {
const body = new FormData();
body.append('video', file.blob); // param name
Axios.post('my_server_url', body, {
headers: {
"Content-Type": "multipart/form-data",
"Accept": 'application/json',
Authorization: Bearer ${token}
,
'X-Requested-With': 'XMLHttpRequest',
"x-chunk-number": file.headers["x-chunk-number"],
"x-chunk-total-number": file.headers["x-chunk-total-number"],
"x-chunk-size": file.headers["x-chunk-size"],
"x-file-name": file.headers["x-file-name"],
"x-file-size": file.headers["x-file-size"] ? file.headers["x-file-size"] : state.videoSize,
"x-file-identity": file.headers["x-file-identity"]
}
})
.then(response => {
switch (response.status) {
case 200:
console.log("data = ", response.data);
break;
case 201:
console.log("progress = ", ${response.data.progress}% uploaded...
);
next();
break;
}
})
.catch(error => {
console.log("error = ", error);
if (error.response) {
if ([400, 404, 415, 500, 501, 504].includes(error.response.status)) {
console.log(error.response, 'Failed to upload the chunk.');
unlink(file.path);
} else if (error.response.status === 422) {
console.log('Validation Error', error.response.data);
unlink(file.path);
} else {
console.log('Re-uploading the chunk...');
retry();
}
} else {
console.log('Re-uploading the chunk...');
retry();
}
});
}
chunk.digIn(upload.bind(this));