Im using the Expos image picker, and Im gets this output:
Object { "cancelled": false, "height": 468, "uri": "file:///data/user/0/host.exp.exponent/cache/ExperienceData/%2540jbaek7023%252Fstylee/ImagePicker/9a12f0a3-9260-416c-98a6-51911c91ddf4.jpg", "width": 468, }
I could make my image, but I realized that the URL is the local URI of the phones .
I use Redux-Thunk and Axios to send an HTTP POST request:
export const sendPost = ( imageUri, title, content ) => async dispatch => { let response = await axios.post(`${ROOT_URL}/rest-auth/registration/`, { image, <<<<- I can't put image uri here :( it LOCAL path title, content }) if(response.data) { dispatch({ type: POST_CREATE_SUCCESS, payload: response.data.token }) } else { dispatch({ type: POST_CREATE_FAIL }) } }
UPDATE I changed the request
let headers = { 'Authorization': `JWT ${token}`}; if(hType==1) { headers = { 'Authorization': `JWT ${token}`}; } else if (hType==2) { headers = { 'Authorization': `Bearer ${token}`}; } let imageData = new FormData(); imageData.append('file', { uri: image }); let response = await axios.post(`${ROOT_URL}/clothes/create/`, { image: imageData, text, bigType, onlyMe ... }, {headers});
!! sorry for the complexity, but the name of the image variable; image - uri for the image. I did not want to change the name of the original variable name
and on the server, print
'image': {'_parts': [['file', {'uri': 'file:///data/user/0/host.exp.exponent /cache/ExperienceData/%2540jbaek7023%252Fstylee/ ImagePicker/78f7526a-1dfa-4fc9-b4d7-2362964ab10d.jpg'}]]}
I found that gzip compression is a way to send image data. Does it help?