I'm not sure why you're using Base64Encoder/Base64Decoder here, tbh (perhaps you really need to send over the net as text at some point?). Unless it's because you are using only a string for the insert statement?
You can insert binary data into a blob field in the AIR database directly, though you probably do have to use a different syntax for the query: try using sqlStatement parameters instead of a concatenated string : e.g var sql:SQLStatement = new SQLStatement(); sql.sqlConnection = someSqlConnectionInstance; var sqlInsert:String = "INSERT INTO Person VALUES(:personName ,:personEmail ,:personImageData);"; sql.text = sqlInsert; sql.attributes[":personName"] = person.name; sql.attributes[":personEmail"] = person.email; sql.attributes[":personImageData"] = person.image_As_ByteArray; // (however you get that). (There are other good reasons for using sqlStatement parameters, but I'll leave for now). I know you can store the image as a byteArray (perhaps encode a bitmapData with JPEGEncoder or PNGEncoder ?) and read that back out, I'm guessing that it would also take a BitmapData (though you would get no compression with that. It may be easier to stuff it back into an image component, however). If storing as a byteArray of a PNG or JPEG image rather than a bitmapData (*if* storing a BitmapData is possible, that is) then you may need to extract the image from that byteArray using Loader . (I'm unsure as to whether the Image component accepts an encoded byteArray as content in flex3, I know it did not in flex2) Apologies if any of the above is incorrect, it's from memory and from about a year ago at that. I'd take it all back to the very simplest test project if I were you, and just test the simplest thing that will/won't work before taking it further. I found all the image storage / display stuff a bit of a struggle initially, that approach helped me a lot (together with reading the docs in depth!). -----Original Message----- From: flexcoders@yahoogroups.com on behalf of sudha_bsb Sent: Mon 21/07/2008 20:55 To: flexcoders@yahoogroups.com Subject: [flexcoders] air sqlite image loading Hi, I am trying to store an image into Sqlite database from an air application and also trying to display the image by reading data from the database. I am using blob datatype for this. I am getting the following error while doing it... Error #2044: Unhandled IOErrorEvent:. text=Error #2124: Loaded file is an unknown type. This is what i am doing while loading the image from database...resultData is the array result from database var imgData:String = resultData[i].image; trace('imgData'+imgData); var decoder:Base64Decoder = new Base64Decoder(); decoder.decode(imgData); var byteArr:ByteArray = decoder.toByteArray(); trace('bytearr'+byteArr); var img:Image = new Image(); img.load(byteArr); obj.image = img personData.push(obj); Similary while inserting the data... var byteArr:ByteArray = new ByteArray(); byteArr.writeObject(person.image); var encoder:Base64Encoder = new Base64Encoder(); encoder.encodeBytes(byteArr); var encoded:String = encoder.toString() trace('encoder string'+encoded); var sqlInsert:String = "insert into Person values('"+person.name+"','"+person.email+"','"+encoded+"');"; Please help.... Thanks & Regards, Sudha. ______________________________________________________________________ This communication is from Primal Pictures Ltd., a company registered in England and Wales with registration No. 02622298 and registered office: 4th Floor, Tennyson House, 159-165 Great Portland Street, London, W1W 5PA, UK. VAT registration No. 648874577. This e-mail is confidential and may be privileged. It may be read, copied and used only by the intended recipient. If you have received it in error, please contact the sender immediately by return e-mail or by telephoning +44(0)20 7637 1010. Please then delete the e-mail and do not disclose its contents to any person. This email has been scanned for Primal Pictures by the MessageLabs Email Security System. ______________________________________________________________________
<<winmail.dat>>