downloading audio files from mySQL

Creating desktop or client-server database solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
mjones1
Posts: 2
Joined: Fri Nov 06, 2009 12:09 am
Location: Swarthmore College
Contact:

downloading audio files from mySQL

Post by mjones1 » Fri Nov 06, 2009 12:16 am

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

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Fri Nov 06, 2009 12:49 am

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
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

mjones1
Posts: 2
Joined: Fri Nov 06, 2009 12:09 am
Location: Swarthmore College
Contact:

re: downloading audio files from mySQL

Post by mjones1 » Fri Nov 06, 2009 2:07 am

Thanks Mark ... will give that a try.

- mike

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Post by trevordevore » Fri Nov 06, 2009 3:48 am

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
Trevor DeVore
ScreenSteps - https://www.screensteps.com

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

Post Reply

Return to “Databases”