react-native-blob-util icon indicating copy to clipboard operation
react-native-blob-util copied to clipboard

iOS fetch uploads empty file

Open rossicler-hostalky opened this issue 1 year ago • 1 comments

Hi, I'm using the .fetch(...) function to upload files to my server, and there's a problem happening when trying to upload a file with a space in the name. The problem is that the uploaded file is empty, giving me a 0kb file on my server. This issue is happening on iOS 15.5 (iPhone XR). I also tested on iOS 17 and it worked as expected.

How to reproduce

  • Run iPhone XR Simulator with iOS 15.5 installed.
  • Download any sample pdf on the simulator, and create a copy of the same. Let's rename one to "sample_name.pdf" and the other to "sample name.pdf".
  • Try to upload both pdfs to any server.

After you check in your server both files uploaded, you will see that sample_name.pdf will be the correct file, but sample name.pdf will be a 0kb file.

Example code

...
const fileStats = await ReactNativeBlobUtil.fs.stat(filePath);
console.log("File stats: " + JSON.stringify(fileStats)); // here I can see that the file is correctly read from device
const result = await ReactNativeBlobUtil.fetch(
    "PUT",
    uploadUrl,
    {
        "Content-Type": file.type
    },
    ReactNativeBlobUtil.wrap(filePath)
);

Versions:

  • react-native: 0.72
  • react-native-blob-util: ^0.19.6

rossicler-hostalky avatar Jan 24 '24 17:01 rossicler-hostalky

Hi @rossicler-hostalky How did you manage to fix this issue ? I have the same problem

EDIT: found the solution in another issue #117 - https://github.com/RonRadtke/react-native-blob-util/issues/117#issuecomment-1038543713

romainlq avatar Apr 19 '24 06:04 romainlq