Posting photos to Tumblr from AIR

I’m sitting here feeling relatively stupid, and a little ripped off. I invested 4+ hours to do something that I should have been able to figure out in about 5 minutes or less. I have been trying to figure out how to upload an image to Tumblr using their very simple API. After many attempts at sending the binary data from a ByteArray I finally figured it out…duh.Of course there are a few ways to obvtain the FileReference object, and also many events to listen to. I’ll go into detail about all this later maybe, but for now I’m just going to paste the obvious method for posting images to Tumblr. Here’s the code: 

1
2
3
4
5
6
7
8
9
10
11
var vars:URLVariables = new URLVariables();
vars.email = "your@emailaddress.com";
vars.password = "password";
vars.type = "photo";
vars.caption = "This is the photo caption!"; // optional ( and can use html )
 
var request:URLRequest = new URLRequest( "http://www.tumblr.com/api/write" );
request.method = URLRequestMethod.POST;
request.data = vars;
 
file.upload( request, "data" );

Yeah, I know, that was way too obvious, and a lame post, but I am trying to squeeze as much out of my wasted 4 hours as I can, so thanks for reading. 

2 Responses to “Posting photos to Tumblr from AIR”

  1. kathryn Says:

    i do think that the file upload function is not discussed enough when talking about AIR network communication. it is also how the AS3 flickr lib uploads a photo.

  2. Fondea Says:

    Great work.

Leave a Reply