Hi i want to post photo to the django backend. I can easily post with postman. But i cant do it with react native. Here is my post request:
handleSubmit(photoUri){
let formData = new FormData();
formData.append('file',photoUri);
formData.append('name', 'a');
fetch('http://localhost:8000/test/', {
method: 'POST',
body:formData,
}).then(res => res.json())
.then((data) => {
console.log(data);
})
.catch(err => console.log(err));
}
In this post django serializer is like that:
FileSerializer(data=<QueryDict: {'file': ['file:///data/user/0/host.exp.exponent/cache/ExperienceData/%2540anonymous%252Ftez2-1599e0c7-8863-4da6-b20f-5e6e94be9342/Camera/b2116349-cdfb-4309-8d6e-51c9a36be4fb
.jpg'], 'name': ['a']}>):
but with postman it is like this:
FileSerializer(data=<QueryDict: {'name': ['a'], 'file': [<InMemoryUploadedFile: a.jpg (image/jpeg)>]}>):
I think issue is something with InMemoryUploadedFile i cant upload file in this form with react native. How can i do it ?