I am using React Native with Expo SDK 37. My request looks like the following:
export const uploadMedia = async (fileData, s3Data) => {
console.log(fileData.type)
let formData = new FormData();
formData.append('key', s3Data.s3Key);
formData.append('Content-Type', fileData.type);
formData.append('AWSAccessKeyId', s3Data.awsAccessKey);
formData.append('acl', 'public-read');
formData.append('policy', s3Data.s3Policy);
formData.append('signature', s3Data.s3Signature);
formData.append('file', fileData.data);
return fetch(`https://...restofendpoint`, {
method: 'POST',
//skipAuthorization: true,
body: formData
})
}
I am using presigned POST method. I get the following s3 data from another endpoint on our server and can confirm all the correct info is being populated. This works perfectly on iOS but when attempting to upload on Android I get the following error:
Network request failed
- node_modules\whatwg-fetch\dist\fetch.umd.js:473:29 in xhr.onerror
- node_modules\event-target-shim\dist\event-target-shim.js:818:39 in EventTarget.prototype.dispatchEvent
- node_modules\react-native\Libraries\Network\XMLHttpRequest.js:574:29 in setReadyState
- node_modules\react-native\Libraries\Network\XMLHttpRequest.js:388:25 in __didCompleteResponse
- node_modules\react-native\Libraries\vendor\emitter\EventEmitter.js:190:12 in emit
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:436:47 in __callFunction
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:111:26 in __guard$argument_0
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:384:10 in __guard
- node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:110:17 in __guard$argument_0
* [native code]:null in callFunctionReturnFlushedQueue
I originally had all my requests using axios
and tried to see if that was the issue by switching to fetch
api. No avail. Pretty much stumped and at a standstill. Any help would be appreciated.