IOS IMAGE UPLOAD: invalid token error

Hi,
I’m getting an error when I try uploading a picture to a server on IOS. It’s not happening every time. I can’t try / catch this error :

my code :

new Promise((resolve, reject) => {
      const timeout = setTimeout(() => {
        reject(new Error(strings("GET_SIGHT_ERROR")));
        return(0);
      }, 5000);

      let options = {
          headers: {
              'Content-Type': 'multipart/form-data'
          },
          method: 'POST'
      };

      options.body = new FormData();
      options.body.append("app_key", tokenApi);
      options.body.append("img", {
          uri: imgUri,
          type: "image/jpeg",
          name: "photo.jpeg",
      });

      fetch(urlApi, options)
      .then(responseJson => {
        clearTimeout(timeout);
        return (responseJson.json())
      })
      .then(responseJson => {
        clearTimeout(timeout);
        resolve(responseJson);
      }).catch(error => {
        console.warn(error.message);
        clearTimeout(timeout);
        reject(new Error(error.message));
      });

I’m using expo SDK 32 and I work with an Iphone 6s. Thank’s for help !

Hello,

I found a workaround by writing my image base64 to a file using FileSystem.writeAsStringAsync. The error does not happen anymore. We are using ImageManipulator to rotate the image, and my guess is that after the image manipulation sometimes the system deletes the file right before it is used for the request, but I did not verify.