Oskar Feliński
Oskar Feliński

Reputation: 19

expo react-native fetch local file not working after update

Expo SDK v. 31.0.0 I'm fetching localfile to make blob.

const response = await fetch(uri)

uri is something like this: "file:///data/user/0/host.exp.exponent/files/..../rec_1541692353037.m4a"

This perfectly worked in Expo Sdk 30.0.0. After upgrade to v.31 I'm getting error on Android:

Network request failed

Stack trace:
  node_modules\react-native\Libraries\vendor\core\whatwg-fetch.js:504:29 in onerror
  node_modules\event-target-shim\lib\event-target.js:172:43 in dispatchEvent
  node_modules\react-native\Libraries\Network\XMLHttpRequest.js:578:29 in setReadyState
  node_modules\react-native\Libraries\Network\XMLHttpRequest.js:392:25 in __didCompleteResponse
  node_modules\react-native\Libraries\vendor\emitter\EventEmitter.js:191:12 in emit
  node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:349:47 in __callFunction
  node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:106:26 in <unknown>
  node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:297:10 in __guard
  node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:105:17 in callFunctionReturnFlushedQueue

On iOS it's stil working perfectly. I've tried axios, but still got same error.

Upvotes: 1

Views: 4238

Answers (1)

Petr Meca
Petr Meca

Reputation: 36

I had also this problem, and I solved it with the function in this link https://github.com/expo/firebase-storage-upload-example/issues/13#issuecomment-437597679

Put your uri to this function and the function returns the blob.

Upvotes: 2

Related Questions