SDK Version: 42.0.1;
Platforms(Android/iOS): Android, IOS;
expo-camera;
Hello how are you?
I’m a mobile developer! I work with react-native and I have a code in Expo to run on Android and IOS. I’m having a problem uploading with axios.post, which in this case works on the physical Android device, it also works on the IOS emulator, but when I try to upload the same through the physical device (Iphone X), the upload fails returning status 500, the code is the same and the error log doesn’t even reach my server. I’ve tried uploading in several different ways, but the answer is always the same! Status 200 on Android emulator and physical Android device, and also status 200 on IOS emulator. On the iPhone X physical device, the answer is code 500 (internal server error). Could someone help me with this? The code is below.
upload = async() => {
const userTOKEN = AsyncStorage.getItem(‘@TOKEN’)
const url = ‘http://myUrl/api/upload/image/’
const body = new FormData();
body.append(‘image’, {
uri: this.state.imageuri,
name: ‘user.jpg’,
type: ‘image/jpeg’
});
axios({
url: url,
method: ‘POST’,
headers: {
‘Authorization’: Bearer ${(await userTOKEN).toString()}
,
},
data: body
})
.then(response => {
response.data
/ console.log(response.data); /
/ this.setState({ modalUpload: false }) /
/ Alert.alert('Data: ', response.data) /
}).catch(function (error) {
console.log(error);
});
};
Answers: Android Emulator (Any version): => Status: 200 , response.data = http: //myUrl//imagens/prova.jpg;
Android Physical Device (Android 11): => Status: 200 , response.data = http: //myUrl//imagens/prova.jpg;
IOS Emulator iPhone 12 Pro Max (IOS 14.5): => Status: 200 , response.data = http: //myUrl//imagens/prova.jpg;
Physical Device IOS Iphone X (Any version): => Status: 500 , console.log (error) = response: 500;
Can you tell me if it’s Apple security related? Does it have something to do with the difference between browsers?
Remember that I’m only using VSCode version 1.55.2, both on Mac and Windows.