gaber79 gaber79 - 1 year ago 51
Ruby Question

mp3 recording using recorder creates a blob. but when sent to server, it has a playtime of 0 seconds

I'm managing to record audio using the recorderjs. It creates the audio. I'm using ruby rails. I save it. It sends the file correctly to my server. When I go to test and see if the audio is the same. It doesn't play and has a play time of 0 seconds.

I want to record an audio file that is 2-5 seconds long. then save that file on the server and it will be linked to a word.'public/mp3s/' + filename, 'wb') do |f|

Is there something wrong with my write method here?

Answer Source

It is likely that you have an encoding error, or a typo generating an empty file. The param could be a binary octet stream instead of base64 for instance. Or it could be coming in as a different key, in which case you'd make an empty file.

If you're on mac or linux, try using the file command on the written file. The command should look at the magic byte, and if it is an MP3 you should see something along those lines.

Likewise, if you cat, hexdump, or notepad the file that rails saved, and the generated one you should be able to see any differences.

params[:mp3data] may also be nil

in development mode, the rails server should list the incoming params.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download