Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: completely and utterly confused with NSImage + MySQL



The BLOB column type in MySQL is substantially slower than saving the binary data as individual files in my experience. If you can get by saving the images to files and storing path information instead, I'd recommend it. The overhead is minimal for single images, but as you have more and more images, the speed difference is very obvious.

As for the other response you got, an image is likely to have \x0 (null) bytes in its data. Since a C string uses that character as its terminator and you're grabbing a C string, you may not be getting all of the data. With this type of data, you cannot rely on a specific terminator and must instead know the length. Use NSData's bytes and length for this.

On Feb 25, 2006, at 3:57 PM, Eric Smith 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: http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >completely and utterly confused with NSImage + MySQL (From: Eric Smith <email@hidden>)
 >Re: completely and utterly confused with NSImage + MySQL (From: Andrew Farmer <email@hidden>)
 >Re: completely and utterly confused with NSImage + MySQL (From: Eric Smith <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.