Re: [Mysql-cocoa-users] Inserting and getting blobs
Brought to you by:
sergecohen
|
From: Jerome R. <jer...@fn...> - 2002-07-26 05:57:56
|
Thanks for your answers. Now, I'm able to insert Images in my DB. Here is how I've done it (it may not be the best solution) MCPConnection *connection; NSImage *theImage; NSData *representationOfTheImage; NSString *stringToInsert; NSString *insertQuery; ...... //The TIFFRepresentation method have an option to compress data, it's not used here, but it should representationOfTheImage = [ theImage TIFFRepresentation ]; stringToInsert = [ connection prepareBinaryData: readData ]; insertQuery = [ [ NSString alloc] initWithFormat: @"INSERT INTO PHOTO (PHOTO) VALUES ( \"%@\") ", stringToInsert ]; and then you just have to lauch the query . About the size of blobs, I use longblob. When I started my tests, I used simple blobs, and when my data was big, it "seemed" to be inserted correctly in the DB (no error, and a simple select in the terminal showed me that line was inserted). But when I tried to get this blob with my tests, the program simply crashed (error 255). I hope it could help if someone needs it. Jerome Rabas. |