file is not readable in FIleSystem.readAsStringAsync in IOS

  1. SDK Version: version 42.0.0
  2. Platforms(Android/iOS/web/all): IOS

i tried to read a file saved in IOS device as followed:
const signature = await FileSystem.readAsStringAsync(url, { encoding: "base64", }).catch((e: any) => { alert("error in SendFileToGoogle: ${url} ${JSON.stringify(url)} ${JSON.stringify(e)}"); });
when I pass the following string it will throw an error saying “file sth is not readable”
string: “1400_%D8%AE%D8%A7%D8%B7%D8%B1%D9%87.caf”
but if I pass a normal string like “1400_nameOfStringInEnglish.caf” it will work properly
any suggestions why this is happening?

It looks like your url contains some URL-encoded characters, please try doing something like that:

const decodedUrl = decodeURIComponent(url); // or maybe try decodeURI(url)
const signature = await FileSystem.readAsStringAsync(decodedUrl, { encoding: "base64" });

Edit: after decoding the string you provided: "1400_%D8%AE%D8%A7%D8%B7%D8%B1%D9%87.ca" - it contains some non-ascii characters (Arabic?). You should avoid filenames containing such characters - they might be not supported properly

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.