I want to upload a picture from phone (android) to a server (Editing avatar of a profile). To select the picture i am using react-native-image-picker.
This is my API-Call
request
.post(apiurl)
.set("auth", token)
.attach('avatar', avatar)
.end(async function (err,res) {
if(res.status === 200) {
console.log("Update views...");
}
});
As far as is read and understood the docs, i just need to pass the filepath to the .attach function. So mine looks like this (android):
avatar = file:///storage/emulated/0/path/on/phone/new_avatar.jpg
I get the path from the react-native-image-picker and add the file:// at the beginning.
But what am I missing?
In the server logs we can see that it returns 500. In our API-Test class, at least as far as we tested it, it only returns 500, when it couldn“t find the file, e.g. a wrong path was passed as an argument.
Cheers and thanks in advance!