Flickr Uploadr, start to finish now

Starting at Flickr a short nine months ago, I was given the state of the Flickr Uploadr and told to make it better. Better meant many things. It meant cross-platform so we could move forward with one codebase. It meant localized in all of Flickr’s languages without hackery. It meant new features that would make uploading easier and encourage people to add metadata to their photos. And while we didn’t explicitly talk about it at the time, better meant open source.

Settling on a platform

Straight C? No. Java Swing? Adobe AIR? XULRunner? So many choices, each with advantages and disadvantages. I ended up choosing to work with Mozilla’s XULRunner, which is what makes up the guts of Firefox and Thunderbird. The main advantages of XULRunner were the ability to link in outside code libraries (like GraphicsMagick) and the availability of real multithreading.

Learning the hard way

Since the project began I’ve jumped more than a few hurdles. I documented many of the more exciting problems on my blog (rcrowley.org) as I went. Crash course follows:

Cross-platform XPCOM (a howto)

Working from Mark Finkle’s crash course for Windows got me halfway and some other scattered resources helped to piece together the skeleton of an app that will run on both Windows and OS X. The code has evolved quite a bit since then but this process got me on my feet.

XUL overlays demystified

As apps grow you naturally need to break files up to save your sanity. I never found the crystal clear example of overlays that I wanted, so after I trial-and-errored my way out of the corner, I wrote out this common use case that Uploadr uses in several places.

Threading in Gecko 1.9

I’ve been developing against XULRunner 1.9 (and therefore Gecko 1.9) which are the underpinnings of Firefox 3. The thread primitives made available in 1.9 are much nicer than in Gecko 1.8. Uploadr uses a background thread for event queuing and this is a stripped down example of that same pattern.

MD5 in XULRunner (or Firefox extensions)

The Flickr API requires developers to sign calls with MD5. MD5 is built right into PHP but is conspicuously missing from JavaScript. There are JavaScript implementations out there but (just for kicks), here’s how to take advantage of Mozilla’s built-in hashing library.

Fun with Unicode!

Flickr has, from the very beginning, been an international place. Well before it was available in eight languages, it would accept user input in any language through the magic of UTF-8. Uploadr carries on this tradition but to bridge the gap between Windows’ UTF-16 Unicode support and GraphicsMagick’s non-Unicode-iness, some hacks had to be liberally applied. This code has changed a bit since, so check the latest out in Flickr Subversion.

Video interview with the Yahoo! Developer Network

Jeremy Zawodny from the Yahoo! Developer Network came up to San Francisco to chat about the new Flickr Uploadr a few months back. We talked about the development process, open source and where the future might lead.

The future is here now with an extension API ready for use in version 3.1. Check out the documentation and helloworld extension or check out the full source code and build tools.