Uploading file blob as a stream


#1

I’m working on an Expo app that will submit short audio clips to Amazon Lex for speech-to-text processing. I’ve read other topics + questions, and think what I’m experiencing seems new.

  const uri = this.recording.getURI();
  const response = await fetch(uri);
  const blob = await response.blob();

I’m using this code to construct a blob from my local file, and then sending to lex with “blob” as the inputStream parameter. It works in the simulator, but not on an actual ios device. On both devices, the contents of “blob” look the same when I log them to the screen.

{"_data":{“size”:48792,“blobId”:“077A…”,“type”:“application/octet-stream”,“offset”:0,“name”:“recording-E8ECDDD…E7F.caf”}}

But while it works in the simulator, on my real iPhone X I get an error back from Lex complaining that “Expected params.inputStream to be a string, Buffer, Stream, Blob, or typed array object”.

Anyone have any suggestions? I can’t find anything else in the Expo FileSystem library that looks like it would help with uploading or file conversion.


#2

hi @marktorrance, that’s really odd that the blob code works in the simulator and not the actual ios device. fwiw, heres the pr for the blob code https://github.com/facebook/react-native/pull/11573 – it might be helpful to see how blob is implemented under the hood on the ios end.


closed #3

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