Re: Uploading image via HTTP POST
Re: Uploading image via HTTP POST
- Subject: Re: Uploading image via HTTP POST
- From: Daniel Meachum <email@hidden>
- Date: Fri, 22 Jan 2010 12:56:36 +0900
I did try your suggestions with the different types of encoding but the resulting string still returned nil. You're right about the Tumblr post method. I looked at the Tumblr API again and they do have a form upload method that I implemented instead of what I was trying and it worked well. Thanks for your help--- I really appreciate it!
Daniel
On Jan 22, 2010, at 6:32 AM, Jens Alfke wrote:
>
> On Jan 21, 2010, at 8:39 AM, Daniel Meachum wrote:
>
>> [[NSString alloc] initWithData:imageData encoding:NSUTF8StringEncoding]];
>
> That's not going to work. Not all series of bytes are valid UTF-8, and in non-textual data like an image you're practically guaranteed to run into illegal UTF-8 sequences pretty quickly. The result will be a nil NSString.
>
> If you want a string encoding that supports arbitrary byte values, try NSWindowsCP1252StringEncoding, which is the default encoding used on Windows. (It's a superset of ISO-8859 that includes encodings for 80-9F.)
>
> You also haven't done any URL-encoding of the resulting string. Call stringByAddingPercentEscapesUsingEncoding: on the resulting string, but use NSWindowsCP1252StringEncoding as the encoding parameter (or whatever other 8-bit encoding you used.)
>
> —Jens
>
> PS: Off-topic, I can't believe the Tumblr engineers invented a protocol that's going to almost triple the size of the image data. It's not REST, or even the normal way that HTTP forms upload file attachments. Sigh.
>
_______________________________________________
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