Files are not sent to the server from Android

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);
      });
  }
};

Hi @Rich

Welcome to our community and thank you for trying out Backendless.

It appears that there might be a need to configure the file provider. Android’s operating system could be restricting the app from sending files to the network and it’s likely that specifying which services can access which resources is necessary.
Consider checking the Android file provider configuration and ensure that the app has the required permissions to send files over the network.

Regards,
Viktor

Turns out the problem was that I made the function asynchronous and because of that sending the file didn’t work. I should have just made the image processing asynchronous instead of uploading.