Skip to content

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

@0xori

Description

@0xori

Environment

Environment:
  OS: Windows 10
  Node: 8.11.0
  Yarn: 1.7.0
  npm: 5.6.0
  Watchman: Not Found
  Xcode: N/A
  Android Studio: Version  3.1.0.0 AI-173.4907809

Packages: (wanted => installed)
  expo: ^30.0.0 => 30.0.1
  react: 16.3.1 => 16.3.1
  react-native: https://github.com/expo/react-native/archive/sdk-30.0.0.tar.gz => 0.55.4

App target - Standalone & Client for testing

Steps to Reproduce

  1. use this expo example of recording audio
  2. mix it with this example of uploading to firebase

Expected Behavior

fetching a file URI from the device file system should return a valid response.

Actual Behavior

I'm getting a network error exception

TypeError: Network request failed

and if I'm running with remote JS debug mode I can see this error in 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.

Some Code

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);
            }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions