Re: Saving images to MySQL
Re: Saving images to MySQL
- Subject: Re: Saving images to MySQL
- From: Bas Scheffers <email@hidden>
- Date: Mon, 23 Jul 2007 12:24:18 +0930
That will only really work when you will only ever want to display
them in another Cocoa app. Best to convert to a standard image format
like JPEG.
What are you using to connect to MySQL? I don't work with MySQL, but
a quick google found me "MySQL-Cocoa" and according to its
documentation, it has methods to escape and NSData object so it can
be sent as string in a query.
Hope that helps,
Bas.
On 22 Jul 2007, at 20:10, Mike Abdullah wrote:
Well presumably, you can pass raw data to the database? If so, try
something like:
[NSKeyedArchiver archivedDataWithRootObject: theImage];
and then later:
[NSKeyedUnarchiver unarchiveObjectWithData: databaseData];
Mike.
On 22 Jul 2007, at 11:11, Michael de Vries wrote:
For my first program I am trying to write in Cocoa I need to save
images of products to a MySQL database.
I already have a connection to the database and I can send all
information of a product to the database and retrieve it, but I
don't know how to handle images.
I have searched google, but I have not found any good solutions or
example code.
Probably I have to convert my NSImage to some sort of string
representation and then save it to a BLOB field in the database,
but how do I represent an image as a string?
And at least as important, how do I create an image of it when I
retrieve this data from the database?
Am I thinking in the right direction, or should I handle things
differently?
Tnx in advance, Michael
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
40mikeabdullah.net
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden