pass recording to some api

i am able to use the expo-av to record and play back the recording using simply the uri returned by recording.createNewLoadedSoundAsync() now i am hoping to just read the file using Filesystem.readasstringasync() but it throws error. do i need first save the file as an asset and then only read and upload?

Hi. Do you need to read the contents yourself? Or can you upload the file something like this?

    await this.recording.stopAndUnloadAsync();

    let formData = new FormData();
    formData.append("audio", {
      name: `audio.${fileType}`,
      type: `audio/${fileType}`
    formData.append("user_id", this.userId);

    let options = {
      method: "POST",
      body: formData,
      headers: {
        Accept: "application/json",
        "Content-Type": "multipart/form-data"

    const response = await fetch(apiUrl, options);
1 Like

this shoudl work. i will give it a shot. one other thing i am having trouble is inability call services on localhost. i can access the services using postman or even regular browser if there is no auth on it but cant access from either emulator or physical device.

so i tried this and i am getting error like this:
[Unhandled promise rejection: TypeError: Network request failed]

  • node_modules\whatwg-fetch\dist\fetch.umd.js:473:29 in xhr.onerror
  • node_modules\event-target-shim\dist\event-target-shim.js:818:39 in EventTarget.prototype.dispatchEvent
  • node_modules\react-native\Libraries\Network\XMLHttpRequest.js:574:29 in setReadyState
  • node_modules\react-native\Libraries\Network\XMLHttpRequest.js:388:25 in __didCompleteResponse
  • node_modules\react-native\Libraries\vendor\emitter\EventEmitter.js:190:12 in emit
  • node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:436:47 in __callFunction
  • node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:111:26 in __guard$argument_0
  • node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:384:10 in __guard
  • node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:110:17 in __guard$argument_0
  • [native code]:null in callFunctionReturnFlushedQueue

Also you can see my call works fine in postman. i tried deploying the service on cloud and even there it does not work so problem is not localhost connection here. any pointers?

Hi, try to be sure your problem is not something like this.

In the past was an issue with older expo version.

i was able to solve my problem. i just read the file as base64string and passed it to the api which saved it and did further processing on it.