Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tumblr API - how to upload multiple images to a Photoset

I am able to upload one picture but I can't create a photoset with multiple images using API.

Documentation says: Paramater: Array (URL-encoded binary contents)

One or more image files (submit multiple times to create a slide show)

Does anyone know how to do it?

like image 501
Milos Blasko Avatar asked Jul 29 '11 20:07

Milos Blasko


People also ask

How do you upload more than 10 pictures on Tumblr?

You can choose up to 10 images, then drag to rearrange them. If you've already added photos, you can add more by clicking the camera icon below them that says "Add another."

How do you make a photoset on Tumblr?

Just grab a photo and place it where you'd like. Hover over an image to add a caption. Add a note for your followers and tags so your amazing photos can be discovered by other users. And preview, save, or publish your amazing work!


2 Answers

It's kind of a painful process, but I figured it out after studying the python code Tumblr posted. In short, it requires getting the hexadecimal for the photo and then doing some substitutions.

I've created a simple iOS / iPad / iPhone project on GitHub that uploads multiple photos to photosets using the Tumblr API, based heavily on the ASIHTTPRequest+OAuth project. It works so far in my limited testing -- feel free to make use of it and let me know how it goes.

like image 106
Victor Van Hee Avatar answered Nov 15 '22 11:11

Victor Van Hee


The new PhotoUpLink for iPhone uploads true Tumblr photosets. It is a free download from the App Store at http://uplink.to/5o example photosets at http://photouplink.tumblr.com

The Tumblr uploader is based on @VictorVanHee's epic. I did optimize the code by switching to straight C for the NSData stringWithoutURLEncoding subroutine:

- (NSString *) stringWithoutURLEncoding
{
    NSString *hexDataDesc = [self description];
    hexDataDesc = [[hexDataDesc stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]] stringByReplacingOccurrencesOfString:@" " withString:@""];

    int hlen = [hexDataDesc length];

    NSString *hexDataDescU = [hexDataDesc uppercaseString];

    const char *hexcString = [hexDataDescU cStringUsingEncoding:NSASCIIStringEncoding];

    char *newStringC = malloc(hlen *3);
    memset(newStringC, 0, hlen *3); 

    int xC= 0, upd = 3000, value = 0;

    char *componentC = malloc(5);   // = "XX";

    componentC[2] = 0;

    const char *px = "%x"; char ptc = '%';

    for (int x=0; x<hlen; x+=2)
    {                           
        componentC[0] = hexcString[x];
        componentC[1] = hexcString[x+1];

        value = 0;
        sscanf(componentC, px, &value);
        if ((value <=46 && value >= 45) || (value <=57 && value >= 48) || (value <=90 && value >= 65) || (value == 95) || (value <=122 && value >= 97)) //48-57, 65-90, 97-122
        {  
            newStringC[xC++] = (char)value;
        }
        else
        {
            newStringC[xC++] = ptc;
            newStringC[xC++] = (char)componentC[0];
            newStringC[xC++] = (char)componentC[1];
        }
    }

    NSString *newString = [NSString stringWithCString:newStringC encoding:NSASCIIStringEncoding];
    NSString *aNewString = [newString stringByReplacingOccurrencesOfString:@"%20" withString:@"+"];

    free (newStringC);
    free (componentC);

    return aNewString;
}
like image 33
user1569282 Avatar answered Nov 15 '22 12:11

user1569282