New Adobe AIR App: MediaWiki Uploader

As part of the Flex 3 launch I needed to upload about 70 images for the feature introductions. Those of you who use MediaWiki (the wiki system on Labs) may know that it doesn’t support uploading multiple files at once. Each upload to the Labs wiki requires choosing the image via the file chooser and checking a box saying that you own copyright. Rather than do this work myself I decided to see if I still remembered how to code and wrote up a quick app using Adobe AIR so that I could upload lots of images at once. I’m making the app available to you all under the MIT license to do with what you please.

Download the AIR (requires Adobe AIR Beta 1)
Download the source (in theory you should be able to import this as a project into Flex Builder)

This app was interesting to build as it had a few interesting challenges.

1. Don’t you need to be logged in to upload?

Yes! And since this is an AIR application it wasn’t sharing my session with Firefox. So I wrote a login service (HTTPService) to execute the login for me (against my staging server). Easy enough except that it was difficult to tell when things were going wrong due to not wanting to add lots of debugging code to the app. So I used my trusty network sniffer (I used the one that comes with JRun but lots of folks use Wireshark or Charles) to figure out where I was going wrong and got the login working. One thing I noticed was that the response on a successful login (and also upload) to my testing wiki was a 302 redirection which the Player did not follow. However it treated the call as a success, and since I wasn’t going for solid code I let it be.

2. How do you go about uploading the image?

I went to the upload page and looked at the source to figure out the parameters that were needed. Believe it or not, this is my first Flex app where I’ve done file uploading. Fortunately the docs for FileReference.upload were pretty easy to understand. I was able to see most of the variables that I needed to set by looking at the form items and filled in the URLVariables to be sent along with the upload request. I created a DataGrid where you can edit the display name, but I didn’t actually want to change the names so I didn’t even test to see if my changes would have worked.

So now I could upload multiple images to my staging server (I actually did two different staging servers because I didn’t want to corrupt the real staging server). This allowed me to shake out a minor difference between the two so now my system could upload to both. But then I faced my final challenge…

3. The Labs wiki doesn’t use MediaWiki’s account management, it uses’s!

Oops! I thought I might have just wasted a few hours of coding since I wouldn’t be able to do my real uploads with my fancy new tool. Then I had a thought…the http session information and cookies are shared between HTML and Flash in AIR. All I need to do is use an HTML control, navigate to the wiki and sign in there, then I don’t need to use my custom login stuff for this particular wiki. So I created a new Window, put an HTML control in there (nice job Gordon!), threw in a TextInput so I could quickly change the location, and away we went. Final complication though is that login on is through https but all of the other urls were http. The HTML control didn’t seem to like moving back and forth. So I simply used the TextInput to change to some urls that I knew would work, and despite the fact that sometimes the redirections didn’t work, when I then went to the Labs page I could see I was logged in. Tried to upload a file, and voila!

My new HTML window gave me an extra bonus, I could now check the wiki’s recently added images special page to ensure that everything was getting up there OK.

Note that this was really written as a utility for me, so I made no usability fixes. The wiki url must basically be the root of the wiki with no trailing slash: e.g., I don’t do any corrections if the url is invalid. And there is no error handling whatsoever. If someone was interested in making it more robust I’d be happy to link to your verision (or repost it).

11 Responses to New Adobe AIR App: MediaWiki Uploader

  1. Hi Matt. We are in the process of looking into Adobe AIR. We want to use it for our administration, which is currently a website. We know this blog isn’t an helpdesk, but maybe you would like to help us point in the right direction.We have a PHP backend which uses sessions. How can we create a “login request” which can be remembered by the AIR environment, e.g. for uploading content and so on? Thanx, Gilles

  2. Bob C says:

    Matt-I’m working on a project where I want to be able to share session variables in CF with MediaWiki similar to how the Adobe site connects to Adobe labs. Any pointers on who I could ask about that?

  3. Matt says:

    Sorry, I don’t have any pointers on that. In general you’re just looking for cookies to be shared across subdomains which means your domain in the cookie should be as high-level as possible (for us we’d use

  4. Ben says:

    Matt, this looks like a great app.Anyone know what this means?[RPC Fault faultString=”Error #1096: XML parser failure: Unterminated element.” faultCode=”Client.CouldNotDecode” faultDetail=”null”]

  5. Matt says:

    Looks like you’re simply missing a closing tag somewhere.

  6. John says:

    Hi Matt,Any chance you’ve updated this application for AIR Beta 2 or 3? I’m trying to do so myself, but keep running into the same unclosed tag as an earlier poster, and for the life of me I can’t find it.Thanks

  7. Matt says:

    Sorry, I haven’t updated it in a while and don’t really have the time right now as we get everything out the door.I did make some changes around beta 2 it appears (according to my file system date). Here are the two files I modified:MediaWikiUploader-app.xmlMediaWikiUploader.mxml

  8. Fredrik says:

    Hi.It would be nice if you write some article about adobe air and how you can use it with mediawiki, like just a simpel login with air to a mediawiki site./F

  9. Arthur says:

    Could you provide the .air file for last version of Adobe?thxs,Arthur

  10. Morten says:

    Does this app exist for the newest version of air?

  11. Matt says:

    I haven’t updated the code but I believe it should work.