Re: completely and utterly confused with NSImage + MySQL
Re: completely and utterly confused with NSImage + MySQL
- Subject: Re: completely and utterly confused with NSImage + MySQL
- From: "Corey O'Connor" <email@hidden>
- Date: Sat, 25 Feb 2006 16:45:01 -0800
How about storing the images as blobs instead of character strings?
That way you don't have to worry about any text encoding trouble you
might have. Which, as Andrew pointed out, is probably where your
problem lies. Get the raw data bytes from the NSData with -bytes, not
-cString. They are *not* equivelent.
-Corey
On 2/25/06, Eric Smith <email@hidden> wrote:
> That's pretty unsatisfying... let me ask another question. Is anyone
> on the list saving image data to a MySQL database? If so, how are
> you doing it? Writing a hex representation of the binary seems
> pretty safe.... but it doesn't work
>
> Thanks,
> Eric
>
> On Feb 25, 2006, at 12:31 AM, Andrew Farmer wrote:
>
> > On 24 Feb 06, at 20:36, Eric Smith wrote:
> >> If I take [tempData cString], run it through
> >> mysql_real_escape_string and then read it back into an image,
> >> using [[NSImage alloc] initWithData:...], the result is just a
> >> *portion* of the original image. How much? It depends on the
> >> level of compression. If I save an uncompressed image to the
> >> database, it comes back out as an entire image. What is going on
> >> here?!! Anyone have any ideas?
> >
> > Two words for you: Null bytes.
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
--
-Corey O'Connor
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden