i am facing problems with uploading to graphql(Graphcool) file endpoint.
RN - 0.45.1
react-native-fetch-blob - 0.10.5
snippet - (this one actually shows me the upload progress) -
RNFetchBlob.fetch('POST', GRAPHCOOL_FILE_ENDPOINT, {
'Accept': 'application/json',
'Content-Type': 'multipart/form-data'
},[
{
name: dates + 'mp4',
filename: dates + 'mp4',
type: 'video/mp4',
data: RNFetchBlob.wrap(this.state.selectedVideo[0].uri)
}
]).uploadProgress((written, total) => {
console.log('uploaded', written/total)
}).then((res) => {
console.log(res);
this.setState({
textCamera:'',
cameraActivityIndicator: false
});
this._onRefresh();
}).catch((err) => {
console.log(err);
})
acutalluy i have tried with a lot of alterations -
{
filename: dates + '.mp4',
type: 'video/mp4',
uri: this.state.selectedVideo[0].uri
}
{
filename: dates + '.mp4',
type: 'video/mp4',
data: RNFetchBlob.wrap(this.state.selectedVideo[0].uri)
}
the app crashes using the above.
only the snippet version shows me the progress, altought the file upload is complete and i also get a response but there is no file created at the endpoint.
can anyone help me here?
@michaelspeed , I'm wondering if that's because the file is large which exceeds the heap size limitation. How large are the files? Does this happen on both Android and IOS?
i say we tried with small 3mb and large 10-50mb files. i dont think its about the size, coz for the first one -
{
name: dates + 'mp4',
filename: dates + 'mp4',
type: 'video/mp4',
data: RNFetchBlob.wrap(this.state.selectedVideo[0].uri)
}
we get a upload progress, and the rest it just crashes
@michaelspeed , how does the URI looks like ?
///var/mobile/Containers/Data/Application/61725713-1F1A-4118-BB93-0DADB39F62D4/tmp/trim.08E78A1E-0C3D-4FC6-8A13-8913483259BA.MOV
using react-native-image-picker library
Hey! I think I've found a workaround:
RNFetchBlob.fetch('POST', FILE_ENDPOINT, {
'Accept': 'application/json',
'Content-Type': 'multipart/form-data'
}, [{
name: 'data', // !!!HERE!!! must call "data"
filename: 'anything_you_want',
data: base64data
}])
i can confirm the above is working!
i am closing this issue! if anyone has a better options they can reopen the issue!
Most helpful comment
Hey! I think I've found a workaround: