0
votes

I have an axios call to a presigned url in s3 for upload, this work well in IOS but trow "Netowork Error" in android.

The code is pretty simple but without any other information (the response is empty) I do not kwno how to solve this.

            axios.post(presignedPostData.url, formData, config)
                .then(function (response) { 
                })
                .catch(function (err) { console.log('S3err',err, err.response) })

I use react-native with expo, the axios call work in ios and also in the web version.


UPDATE

The problem seems relative to formdata, if for example I remove the formdata obviously my post not work but the error (missing pre-conditions...) and the status (412) code are ok, but with formdata I've not error description nor status code..


UPDATE 2: the formdata, autogenerated from s3.createPresignedPost (they work in ios and web)

{"_parts":[["Content-Type","video/mp4"],["key","src-058ef4d0-0d49-11ea-8478-3b47e74a5983.mp4"],["acl","public-read"],["bucket","my.bucket"],["X-Amz-Algorithm","AWS4-HMAC-SHA256"],["X-Amz-Credential","mycredentials"],["Policy","mypolicy"],["X-Amz-Signature","mysignature"],["file",{"cancelled":false,"width":1280,"type":"video","uri":"file:///data/user/0/host.exp.exponent/cache/ExperienceData/%myapp%252Fmyapp/ImagePicker/8d68fafa-5c47-4436-9323-dc0d8702dc5d.mp4","rotation":90,"height":720,"duration":1280}]]}

Also tested with fetch (in place of axios), same problem.


UPDATE 3

If I use FyleSystem

`import * as FileSystem from 'expo-file-system';

//mediaArray['file'] = file;
mediaArray['fileALT'] = FileSystem.cacheDirectory+name

I'm able to du the upload with code 204 but the file uploaded isn't right. Maybe there is a permission problem on imagepicker. Still not working the process but with this new informations maybe someone can have an idea.

1
Can you post your formdata? - Sarmad Shah
Hi, tnx, I've posted my form data in the last update - red

1 Answers

0
votes

the problem seem to be solved, I'm looking to upload video, the file picker add "video" as type, this works on IOS and WEB but not in ANDROID, to get work also in android the type had to be more specific, for example "video/mp4" for .mp4 video o "video/mov" for mov video etc.. I hope that this help someone to achieve mutlipart/form-data in android.