a photo uploader for Linux, Mac and Windows

jUploadr API

Have a photo upload site that you love more than Flickr or Zooomr? Want to use jUploadr with it? Well, you can customize jUploadr to upload to your site. With a fair amount of Java knowledge, you can build a jUploadr plugin that uploads to a third party site using jUploadr's core features. Here's the JavaDoc to get you started

Starting out

First off, jUploadr is written in Java and uses the SWT toolkit from IBM. It's probably a good idea for you to have solid knowledge of Java, threading and UI design. You won't have to code much in the way of UI, but you will have to provide some small dialogs --such as the account and tags and privacy dialogs.

The first thing you'll need to extend is the ImageUploadAPI class. This singleton object provides the core of interaction with the remote site and defines several callback methods that are executed in response to user interaction with jUploadr.

Accounts

You will need to extend the Account object and integrate it into your ImageUploadApi class. You may add features and methods to the object, but they will only be used inside of the ImageUploadApi implementation. Accounts often contain user preferences and as such have a built-in mechanism for saving their state. Every bean-style (those of the style setXXX and getXXX ) property of an account is persisted when the save() method is called.

Authentication

Before jUploadr makes a network call, it first checks whether or not the current Account is authenticated. It does this by calling Authenticate. This method is passed an account to authenticate (which might be the null account), and any authentication steps happen during this method invocation.

Configuration

The method getConfigurationDialogs() returns the an array of Classes that are created at runtime and added as configuration tabs. These classes should extend BaseConfigurationForm or implement ConfigurationForm. You are free to implement any method of saving your configuration properties, but due to the cross-platform nature of jUploadr, using java.util.prefs is highly recommended.

User Interaction

The thumbnailRightClicked() and windowRightClicked

Lifecycle

Initialization

When either the application starts up or a user switches to your implementation of ImageUploadApi (by selecting either an account on your site, or by trying to create a new account on your site), the initialize() method is called. It's up to you what you do during this method call. For example, the Flickr API fetches your tags and your photosets.

Upload

Now we get to the meat --uploading photos. When a photo is to be uploaded, jUploadr calls the upload((UploadImage imageAttributes, UploadStatusMonitor monitor) method JUploadr uses the HttpClient HTTP library for all its network use. Your job inside of upload is to obtain an HttpClient object, read the bytes out of the UploadImage you are given, and use the HttpClient to upload these bytes to your site. The HttpClient object can be obtained with a call to HttpClientFactory.getHttpClient(). This returns a HttpClient object configured according to the user's preferences. You do not have to worry about proxies or throttling. It's already handled for you.
When posting via HttpClient, you need to assemble your parameters as a list of Part objects. When it's time to create the Part that represents the file, use a MonitorFilePart and pass in the UploadStatusMonitor. This takes care of updating the progress bar at the bottom of the UI.

Errors

Errors during upload should result in either a ProtocolException or a CommunicationException being thrown. Both of these exceptions are expected by jUploadr and handled gracefully.