ios – file:/// url does not work in FormData [React Native]

[ad_1]

In my react-native app once I take an image utilizing react-native-vision-camera or resize a picture by way of expo-image-manipulator, I obtained the next url for the ultimate file/picture:

file:///var/cell/Containers/Information/Software/CB881575-5B7D-4B1D-A016-CF6A4F025AB4/Library/Caches/ImageManipulator/F1233844-82D9-4281-9865-7B382F3F0F84.jpg

Then I create a FormData to add the supply by way of axios:

  formData.append(title, {
    uri: uri.exchange("file://", ""),
    kind: "picture/png",
    title: "filename.png",
  });

Notice that I exchange file:// within the url, as many solutions each right here and on GitHub mentioned.

Lastly:

  axios.publish(url, formData, {
    headers: {
      Authorization: "Token ...",
      "Content material-Sort": "multipart/form-data",
    },
    transformRequest: (formData) => formData,
  });

And it does not work, the picture is not uploaded on the backed, if I attempt to print the shape knowledge too there isn’t any photos inside.

Notice: each picture/png or picture/jpg do not work.

Does somebody have had the identical difficulty?
Thanks

[ad_2]

Leave a Reply

Your email address will not be published. Required fields are marked *