I have a React Native
app, there is a screen to upload a logo
(an image). When the logo gets uploaded, Django should receive the image, save into an user row and create the file into local assets folder (as usual). The problem is, i don't even know if i am sending the data from React Native in a correct way, but Django REST API
is receiving the image as an Python dict
. I'm following the instructions from many other people, but still not working, here's how i load the logo into a React Native FormData instance:
const fd = new FormData();
fd.append('logo', {
name: logo.fileName,
uri: logo.uri,
type: logo.type,
});
The logo
variable is an Asset instance, from react-native-image-picker library.
And here, how Django receive the data, with pdb (Python debugger):
For a better look:
{'_parts': [
['logo', {
'name': 'logo.png',
'uri': 'file:///data/user/0/com.micandidato/cache/rn_image_picker_lib_temp_9b3907e0-3f13-4ad5-9ca9-13f491473440.png',
'type': 'image/png'
}]
]}
I'm pretty sure Django is not going to save this object as an image. The request method from React Native is PATCH
(if relevant). Thanks.