Hi.
I used the backendless library on Draftbit to send a photo file to the server. But unfortunately the server returns an error if the file is sent from android. There is no such problem on iOS.
Here is the error I get when sending the file:
Error: “Network request failed” in index.android.bundle:163:8654 << index.android.bundle:139:1279 << p@index.android.bundle:139:529 << callTimers@index.android.bundle:139:2680
And here is my code that executes the file sending:
import Backendless from 'backendless';
import * as ImageManipulator from 'expo-image-manipulator';
import 'react-native-get-random-values';
import { v4 as uuidv4 } from 'uuid';
export const upload = async image => {
Backendless.initApp(
'97B5F55F-56C7-7FAD-FF23-40F444606800',
'DDAC38D2-A8DA-42A8-9A3B-988E4C9C44AC'
);
const source = await ImageManipulator.manipulateAsync(
image,
[
{
resize: { width: 100, height: 100 }
},
],
{
base64: true,
format: 'jpeg',
}
);
if (source) {
console.log(source);
const resp = await fetch(`data:image/jpeg;base64,${source.base64}`);
const blob = await resp.blob();
Backendless.Files.saveFile('users/avatar', `${uuidv4()}.jpeg`, blob)
.then(function (fileURL) {
console.log(fileURL);
})
.catch(function (error) {
console.error(error);
});
}
};