Borewit/music-metadata

can't get data from google cloud storage URL (audio file)

redimongo opened this issue · 2 comments

Bug description
We currently upload all audio files to Google Storage, and need away to read the file duration from there or while we are uploading the file to there.

I thought this could work as we have the buffer of the file as it is uploading, but could not get it to work.

Expected behavior
to be able to use req.file.buffer to get duration.

Audio file demonstrating the problem
https://storage.googleapis.com/rantshow/1663056224608Test_mp3

I don't know what req.file.buffer is, but if buffer is a Node.js Buffer and filled with the entire audio file content you can use parseBuffer() to extract metadata.

Alternatively, if you wish to prevent to buffer the entire file, but rather stream it to your Google storage, you parse the file after uploading. A specialized reader for S3, the same could be written I guess for Googlecloud storage.

Parsing the stream for metadata and uploading at the same time, will introduce all sorts of issue.

Feel free to re-open if you believe this needs further discussion.