Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file://sdcard/hello.mp4 Unable to upload server #157

Closed
iag520 opened this issue Dec 17, 2019 · 10 comments · Fixed by #189
Closed

file://sdcard/hello.mp4 Unable to upload server #157

iag520 opened this issue Dec 17, 2019 · 10 comments · Fixed by #189

Comments

@iag520
Copy link

iag520 commented Dec 17, 2019

I need to upload to the server

@hyochan
Copy link
Owner

hyochan commented Dec 26, 2019

Are you sure you've grabbed the uri from stopRecorder? Your uri doesn't look correct.

@Atuldhaka
Copy link

Please give update for this, as i am getting the same path from stop recorder and my api gives network error for this every time, but in ios file gets uploaded.

@hyochan
Copy link
Owner

hyochan commented Mar 25, 2020

Screen Shot 2020-03-25 at 7 20 27 PM

@Atuldhaka I've just tested out and it is giving me different path. Have you tried our Example app?

@Rishabh02
Copy link

Rishabh02 commented Apr 17, 2020

hi @hyochan
I am also getting the same path on onStopRecord and onStartRecord. So when I am uploading the uri to my server on Android it's throwing me below exception

Could not retrieve file from content Uri file://sdcard/hello.mp4 java.io.FileNotFoundException: /audio.mp4 (No such file or directory)

But I checked in my emulator the same file is creating under the same folder

I am getting below URI, check logs below:
LOG uri onStartRecord: file://sdcard/hello.mp4
LOG result Stop-- file://sdcard/hello.mp4

Please help me to resolve this.

@hyochan
Copy link
Owner

hyochan commented Apr 17, 2020

@Rishabh02 Have you tried our example project?

@Rishabh02
Copy link

i just fixed the bug, I am not givinng any path in android now so it is saving to it's default location and working fine then

const path = Platform.select({
ios: 'hello.m4a',
});

Check Logs
LOG uri: file:///sdcard/sound.mp4
LOG Stop file:///sdcard/sound.mp4

@hyochan
Copy link
Owner

hyochan commented Apr 17, 2020

I am not quite clear about what you've written above. So you don't have any issue with it?

@Atuldhaka
Copy link

Atuldhaka commented Apr 20, 2020 via email

hyochan added a commit that referenced this issue Apr 20, 2020
@hyochan
Copy link
Owner

hyochan commented Apr 20, 2020

Oh! I understand the problem now~! Thanks.

I've released to 2.5.1 once again.

@hyochan hyochan mentioned this issue Apr 20, 2020
hyochan added a commit that referenced this issue Apr 20, 2020
* Upgrade example project to recent RN

* Resolve #157 once again

* Release 2.5.1
@hiendc170196
Copy link

Please help me fix this issue, after I record audio, then I upload it to server, the upload process is fine but when I get the url of it, it's just an empty source. My code to upload is

function createFileFormData(attachment: DocumentPickerResponse) {
  const formData = new FormData();
  const fileURI = attachment.uri;

  const imageData: ImageData = {
    uri: fileURI,
    type: 'audio/aac',
    name: attachment.name + '.mp3',
  };

  formData.append('file', imageData);
  return formData;
}

export async function uploadAudioFile(attachments: any[]) {
  let resizedImages = attachments;
  if (attachments.length === 0) {
    return [];
  }
  console.log({attachments});
  // Upload images
  try {
    let uploadResponses: UploadImageResponse[] = await Promise.all(
      resizedImages.map(attachment => {
        return api('/upload/upload-audio', createFileFormData(attachment), {
          method: 'POST',
          headers: {'Content-Type': 'multipart/form-data'},
        });
      }),
    );
    console.log({uploadResponses});
    return uploadResponses;
  } catch (error) {
    console.log({error});
  }
}
the uri after I record is 
`file:////data/user/0/vietgroup.jp/cache/sound.mp4`
the path to config record I set is: 
export const path = Platform.select({
  ios: 'hello.m4a',
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants