DEV Community

Cover image for React Native : How to upload an image to Cloudinary.

React Native : How to upload an image to Cloudinary.

OGcodes on March 30, 2020

Prerequisites Things you need to know are: Familiar with React Native elementary setup, if not get started here, You can als...
Collapse
 
clembesso profile image
clembesso

Hello, this works for me with a valid url like yours 'res.cloudinary.com/ogcodes/image/u...' but when I pass the response.uri, it respond with a 400 error like the url is not valide. Do you have any issue ?

Collapse
 
clembesso profile image
clembesso

here is the log of my response.uri inside the ImagePicker : file:///Users/clement/Library/Developer/CoreSimulator/Devices/62E85527-A2AC-46CD-B517-E6039F99E056/data/Containers/Data/Application/2CC48963-39E0-4DF7-98FB-7710A819260F/Documents/images/CF21FDB9-04EA-4BA5-BD4E-AC683B9A34B1.jpg

Collapse
 
godswillokokon profile image
OGcodes

Hello, can I see your code? Did you find a fix, sorry for the delay in response

Collapse
 
tkkm7 profile image
tkkm7

For everyone who has problems uploading on android. I got a "Network Request Error" that said:
"node_modules/whatwg-fetch/dist/fetch.umd.js:535:17 in setTimeout$argument_0"

I found a solution for me:
I changes line 19 of the above code to

const type = application/${response.type};

this did the trick =)

Collapse
 
janeviceral08 profile image
janeviceral08

I tried this but when im uploading. the alert says "An Error Occured While Uploading"

Collapse
 
godswillokokon profile image
OGcodes

Hello, can I see your code and where exactly it gives you this error? Sorry for replying late

Collapse
 
godswillokokon profile image
OGcodes

Hello @janeviceral08 thank you for reaching out, can you produce a
a use case of your code and error(screenshot), at what point did you get this error?

Collapse
 
danibordoli profile image
DaniBordoli • Edited

Hello!i get an error Network request failed while fetch , may i know how to fix it ? Thanks

Collapse
 
godswillokokon profile image
OGcodes

does this error happen on iOS? for Andriod add android:usesCleartextTraffic="true" in AndroidManifest.xml.

like this :




android:usesCleartextTraffic="true"
.......>
.......

Collapse
 
datdang2311 profile image
Đặng Quốc Đạt • Edited

Hello, i upload image and response with a 400 error : "Request failed with status code 400".
please help me.
Thank you.

Collapse
 
choows profile image
c

Hi i get an error Network request failed while fetch , may i know how to fix it ? Thanks

Collapse
 
godswillokokon profile image
OGcodes

can you share your code?