Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9017125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:11:09+00:00 2026-06-16T04:11:09+00:00

I am really stuck with this issue for many days. In my app i

  • 0

I am really stuck with this issue for many days. In my app i need to upload image on tumblr, i have tried various tutorials and updates however none of them is working for posting images on tumblr.Please help me any one if you have done this.

NSData *imageData = [NSData dataWithContentsOfFile:photo];
//stop on error
if (!imageData) return NO;

//Create dictionary of post arguments
NSArray *keys = [NSArray arrayWithObjects:@"email",@"password",@"type",@"caption",nil];
NSArray *objects = [NSArray arrayWithObjects:
                    tumblrEmail,
                    tumblrPassword,
                    @"photo", caption, nil];
NSDictionary *keysDict = [[NSDictionary alloc] initWithObjects:objects forKeys:keys];

//create tumblr photo post
NSURLRequest *tumblrPost = [self createTumblrRequest:keysDict withData:imageData];
[keysDict release];

//send request, return YES if successful
NSURLConnection *tumblrConnection = [[NSURLConnection alloc] initWithRequest:tumblrPost delegate:self];
if (!tumblrConnection) 
{
    NSLog(@"Failed to submit request");
    return NO;
} 
else 
{
    NSLog(@"Request submitted");
    receivedData = [[NSMutableData data] retain];
    [tumblrConnection release];
    return YES;
}

-(NSURLRequest *)createTumblrRequest:(NSDictionary *)postKeys withData:(NSData *)data
{
 //create the URL POST Request to tumblr
 NSURL *tumblrURL = [NSURL URLWithString:@"http://api.tumblr.com/v2/blog/kashifjilani.tumblr.com/posts"];
 NSMutableURLRequest *tumblrPost = [NSMutableURLRequest requestWithURL:tumblrURL];
 [tumblrPost setHTTPMethod:@"POST"];

//Add the header info
NSString *stringBoundary = @"0xKhTmLbOuNdArY---This_Is_ThE_BoUnDaRyy---pqo";
NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",stringBoundary];
[tumblrPost addValue:contentType forHTTPHeaderField: @"Content-Type"];

//create the body
NSMutableData *postBody = [NSMutableData data];
[postBody appendData:[[NSString stringWithFormat:@"--%@\r\n",stringBoundary] dataUsingEncoding:NSUTF8StringEncoding]];

//add key values from the NSDictionary object
NSEnumerator *keys = [postKeys keyEnumerator];
int i;
for (i = 0; i < [postKeys count]; i++) {
    NSString *tempKey = [keys nextObject];
    [postBody appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n",tempKey] dataUsingEncoding:NSUTF8StringEncoding]];
    [postBody appendData:[[NSString stringWithFormat:@"%@",[postKeys objectForKey:tempKey]] dataUsingEncoding:NSUTF8StringEncoding]];
    [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",stringBoundary] dataUsingEncoding:NSUTF8StringEncoding]];
}

//add data field and file data
[postBody appendData:[@"Content-Disposition: form-data; name=\"data\"\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
[postBody appendData:[@"Content-Type: application/octet-stream\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
[postBody appendData:[NSData dataWithData:data]];
[postBody appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",stringBoundary] dataUsingEncoding:NSUTF8StringEncoding]];

//add the body to the post
[tumblrPost setHTTPBody:postBody];

return tumblrPost;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T04:11:11+00:00Added an answer on June 16, 2026 at 4:11 am

    This works for me:

    NSData *imageData = UIImageJPEGRepresentation(yourUploadImage, 0.9);
    NSMutableURLRequest *aRequest = [[[NSMutableURLRequest alloc] init] autorelease];
    [aRequest setURL:[NSURL URLWithString:@"https://www.tumblr.com/api/write"]];
    [aRequest setHTTPMethod:@"POST"];
    NSString *boundary = @"0xKhTmLbOuNdArY";
    //NSString *boundary = [NSString stringWithString:@"---------------------------14737809831466499882746641449"];
    NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",boundary];
    [aRequest addValue:contentType forHTTPHeaderField: @"Content-Type"];
    
    /*
     now lets create the body of the post
     */
    NSMutableData *body = [NSMutableData data];
    [body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
    
    [body appendData:[@"Content-Disposition: form-data; name=\"email\"\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:Tumblr_UserName_Here dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
    
    [body appendData:[@"Content-Disposition: form-data; name=\"password\"\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:Tumblr_Password_Here dataUsingEncoding:NSUTF8StringEncoding]];
    
    [body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary]
                      dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:[@"Content-Disposition: form-data; name=\"type\"\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:[@"photo" dataUsingEncoding:NSUTF8StringEncoding]];
    
    [body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:[@"Content-Disposition: form-data; name=\"data\"; filename=\"upload.jpg\"\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:[@"Content-Transfer-Encoding: image/jpg\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:imageData];
    
    [body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
    
    if(comment available here)
    {
        [body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] 
                          dataUsingEncoding:NSUTF8StringEncoding]];
        [body appendData:[@"Content-Disposition: form-data; name=\"caption\"\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
        [body appendData:[commentString dataUsingEncoding:NSUTF8StringEncoding]];
    }
    
    // setting the body of the post to the reqeust
    [aRequest setHTTPBody:body];
    [NSURLConnection connectionWithRequest:aRequest delegate:self];
    

    Now delegate of NSURLConnection

    - (void)connectionDidFinishLoading:(NSURLConnection *)connection
    {
      if(connection)
        NSLog(@"Success");
      else
        NSLog(@"Something Wrong");
    }
    
    - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error;
    {
       NSLog(@"%@",[error description]);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have been stuck with this issue for a few days now, and really need,
Hi guys I really need some help, I have been stuck in this part
I have run into this issue too many times and need this to be
I realize this question is pretty basic, but I'm really stuck. I have a
I have been stuck on this and don't really know how to go about
I've been stuck on this for a couple of days now, and I'm really
I've been stuck on this for days now, so I'd be really grateful if
I'm really stuck trying to use java wrapper library for opencv's cvMatchTemplate. See this
Hey, I'm really stuck with my project here... I need to know when any
Okay, I think I might be over-complicating this issue but I truly am stuck.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.