Page 1 of 1
downloading audio files from mySQL
Posted: Fri Nov 06, 2009 12:16 am
by mjones1
Have a stack that records and uploads audio to a mySQL database. Trying to create a stack that allows users to hear/download the audio in the database. The audio is uploading correctly, but the file being downloaded is text. Any Idea what I'm doing wrong?
put revDataFromQuery(tab,return,dbid,"SELECT response FROM results where assignment_ID = :1 AND name = :2 AND question = 1", "dbdata") into url ("binfile:test.wav")
Thanks,
Mike
Posted: Fri Nov 06, 2009 12:49 am
by Mark
Hi Mike,
There are often problems with binary data. It will probably work if you base64encode the data before writing it to the database. Retrieve it as base64 and decode it before writing to disk.
Best,
Mark
re: downloading audio files from mySQL
Posted: Fri Nov 06, 2009 2:07 am
by mjones1
Thanks Mark ... will give that a try.
- mike
Posted: Fri Nov 06, 2009 3:48 am
by trevordevore
revDataFromQuery is going to deliver all results as text, not binary data. If you want to extract binary data from MySQL using revDB then you need to look at revDatabaseColumnNamed. Untested but something like this should work:
Code: Select all
put "SELECT response FROM results where assignment_ID = :1 AND name = :2 AND question = 1" into theSQL
put revQueryDatabase(dbid, theSQL, "dbdata") into theCursor
put revDatabaseColumnNamed(theCursor, "response", "theBinaryData") into theError
if theError is empty then
put theBinaryData into url("binfile:test.wav")
else
answer "Error:" && theError
end if