header image

Creative use of Google's Bandwidth

Picasaweb

As some people already know, picasaweb is a photo sharing site run by Google. It's a lot like flickr, if you're familiar with that website. You can post photos, descriptions, tags and comments.

I've used picasaweb for a while now and I really like it. But I also like embedding photos directly in my own site so that my albums match the 'look and feel' of my webpages. I want the same header/footer and page layout.

The other day I had the idea of building 'skeleton' HTML pages that just referenced images stored on picasaweb. That way the album style will match my own website style and the bandwidth of serving images will be taken care of by Google (and not my DSL line). This sounds like a selfish motivation (and it is) but my DSL line is not fast enough to serve the photo content well for a browser. Also, my DSL provider (Verizon) has a fairly draconian acceptable use policy (which means I probably shouldn't be running a webserver at all and I'd rather not attract their attention by serving large images).

Luckily this arrangement (i.e. Google hosts my pictures for me) seems to be actively encouraged by the picasaweb people judging from the links all over picasaweb album view that show you how to "embed this photo" or "embed this album". (Or, notably absent in (at least this version of) the gdata feed, "embed a slideshow of this album").

The trouble is: I am lazy and I don't want to dig through all my albums and click a bunch of links to get the URLs to stick on my local webpages. Luckily for me Google publishes a nifty data API and Reference Guide for how to access picasaweb programmatically. What that means for you non-geeks is that you can (easily) write a computer program to build your local-site-with-links-to-picassaweb for you.

I did this. It was really easy thanks to Google's cool client libraries. These are basically code libraries to make interacting with XML streams that expose the gdata API easier. There are good libraries for a bunch of different languages including Java, Python, .NET, PHP, Objective-C (mac), and Javascript. I chose to use the Java one and wrote the code below in about an hour. It's heavily based on the Java sample code included with the client library. I've left the copyright notice and license link in place are required by my understanding of the legal text.

The code is available on my subversion server. You'll also need the Google Java client library in order to build it (which depends on some classes from Sun called activation.jar and mail.jar, also).

DISCLAIMER: I work for Google. In light of this fact, there are some things I'd like to say now to cover my ass:

  • This code was developed by me on my personal time and is not officially supported or condoned by Google other than to the extent that any random Java code that happens to use their publically released APIs is supported or condoned.
  • Moreover, this code is not supported by me other than maybe via email if you seem like a nice person and I am in a good mood that day.
  • This code is based on copyrighted Google sample code. This sample code was released under the Apache license which explicitly states: "Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form." Moreover I did not use any undocumented or tricky inside knowledge while making this. So, what I'm saying here is that this is in no way trade secret or confidential code.
(none) was last updated (none) and is Copyright (C) 2002-2010 by Scott Gasch (scott@wannabe.guru.org).