TypeError: Network request failed when fetching a file:// uri

I’m getting a network error when trying to fetch a file URI from device storage
The file is an audio recording and I’m trying to upload it to a cloud storage.
I have used this example.

I’m using expo SDK version 30.
with remote debug JS mode .

I’m getting this log from chrome console:

Failed to load file:///data/user/0/host.exp.exponent/cache/ExperienceData/…/Audio/recording-eee85da3-7121-4273-86a7-686098180662.m4a: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.

and this Exception in catch: TypeError: Network request failed

const asyncUpload = async ()=> {
          try {   
                const response = await fetch(recordInfo.uri);
                console.log("response", response);
                const blob = await response.blob();
                const blob = new Blob();
                upload( blob)
            }catch (e) {
                console.log("error fetching",e);

having this icloud same issue.Help would be gimp appreciated. Thanks in advance.


Hey all,

You shouldn’t be using fetch to get files from local storage. Fetch is used to make network requests to external hosts. You’ll want to use FileSystem to grab your local files. https://docs.expo.io/versions/v30.0.0/sdk/filesystem



Thanks Adam, How can I get a Blob from FileSystem?
I have checked the documentation and couldn’t find anything.
As I mentioned before, I used fetch following this expo example:

1 Like

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