Hi! I am uploading an image to a server, imageUri is taken via expo’s ImagePicker, here is the code:
const formData = new FormData()
formData.append('picture', { uri: imageUri, name: filename, type })
await fetch(uploadProfileImageURL, {
method: 'POST',
body: formData,
header: {
Accept: 'application/json',
'Content-Type': 'multipart/form-data'
}
})
On android it works like a charm, but on iOS devices its random, 50% of time it works, and the rest time it gives iOS network error:
“Error processing request body: Error
Domain=ABI25_0_RCTErrorDomainCode=0 “Invalid request Token.”
UserInfo={NSLocalizedDescription=Invalid request token.}”
- URL where I am uploading is HTTPS
- Tried promises instead of async/await but no luck If I try to upload
to a different server, problem is the same, so its not a server side
problem - I tried using axios/XHR but still same error. The only time error
goes, is when I do not append image. If I append string key/values
then it works, but if I append image it randomly does not work. I
have tested on 3 different iOS devices, have same problem. Using
latest expo sdk. - If I use try/catch or .catch (when using promises) the error is not
being caught - On iOS simulator it works 100% of the time