Forum BigDB image file in a DB

Discussion and help relating to the PlayerIO database solution, BigDB.

image file in a DB

Postby eaxis » March 27th, 2011, 12:25 am

Does BigDB support blob format ? Can I store an actual image in the DB ?
If not, any option you can suggest?

Thanks!
eaxis
 
Posts: 5
Joined: March 27th, 2011, 12:21 am

Re: image file in a DB

Postby Henrik » March 27th, 2011, 9:04 am

Yes, one of the datatypes in BigDB is bytearray, use that to store serialized data of any kind.

But storing images in a database is usually a bad idea. What are you going to do with these images later? How many images are there? How large are they? Where do they come from?
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm

Re: image file in a DB

Postby eaxis » March 27th, 2011, 4:18 pm

They would be coming directly from Flash. Each would be about 120k.
Is better approach to store images as files and have urls in the DB ?
Is there a way to pragmatically save images to GameFS ?
eaxis
 
Posts: 5
Joined: March 27th, 2011, 12:21 am

Re: image file in a DB

Postby Benjaminsen » March 28th, 2011, 4:53 pm

eaxis wrote:They would be coming directly from Flash. Each would be about 120k.
Is better approach to store images as files and have urls in the DB ?
Is there a way to pragmatically save images to GameFS ?


You currently can't programmatically save files in GameFS.

as3corelibs does however have both png and jpeg encoders for as3 so you can store images as binary blobs without them taking up 120kb https://github.com/mikechambers/as3corelib
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: image file in a DB

Postby eaxis » March 31st, 2011, 4:41 am

thanks!
Any way you can post a sample code for loading an encoded image from bigDB and displaying it in flash ?
eaxis
 
Posts: 5
Joined: March 27th, 2011, 12:21 am

Re: image file in a DB

Postby cjcenizal » March 31st, 2011, 6:37 am

Eaxis, what Benjaminsen is suggesting is just pulling the data from BigDB as you normally would, with a bigDB.load() request (http://playerio.com/documentation/bigdb/objects). After that, you have a ByteArray of the JPG. I was curious about how to do this, too, and after some Googling I found this possible solution: http://www.bytearray.org/?p=1089. Here's another forum thread describing a similar problem and solution: http://forums.adobe.com/thread/456581. If you end up giving it a shot, please share your results with the rest of us -- I'd love to know how it goes!
cjcenizal
Paid Member
 
Posts: 115
Joined: March 29th, 2011, 12:31 am

Re: image file in a DB

Postby Benjaminsen » March 31st, 2011, 10:12 am

Quick and dirty example of loading images from harddrive and storing them in BigDB. This example does not use the as3corelib. Adding that in I leave as an exercise for the reader.



The upload button becomes invisible while the system is uploading. When done uploading you can reload your browser to verify that the image where stored to the server.

Source here: http://o.ogmy.com/058fdbd38566bd20f303a6b7d218c50c.zip (Flash Builder project)
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: image file in a DB

Postby cjcenizal » March 31st, 2011, 4:33 pm

Thanks Benjaminsen! Just uploaded a picture of myself.
cjcenizal
Paid Member
 
Posts: 115
Joined: March 29th, 2011, 12:31 am


Return to BigDB