Picasaput

Just Another Picasa Web Album Uploader for Linux

Picasaput is just another picasa web album uploader for linux-like systems, and using Picasa Web Albums Data API. This picasaput.tar.gz package includes the java class file, the source and all libraries needed. Note that you must run ./picasaput in the extracted directory if that shell script is not modified. And JRE 1.5 is required.

Install and Usage

Download picasaput.tar.gz package. Extract that file, and cd to the extracted directory. Then execute

$ ./picasaput /dir/to/images/*.jpg

or install it to your home dir

$ ./install

and add $HOME/bin to PATH. You may install it as root to a system dir:

# ./install --prefix=/usr/local

Finally, modify the default (empty) account to your Google Account is a smart idea.

Source Code

Here is the only java source code. To compile and run it, GData Java Client Library and JavaMail Library must in your system and with CLASSPATH set properly.

/*
* main.java
* Requires Google data (GData) API, which further needs JavaMail API.
* Most codes copy from Picasa Web Albums Data API Developer's Guide
* (http://code.google.com/apis/picasaweb/gdata.html#Find_URL).
*/
import com.google.gdata.client.photos.PicasawebService;
import com.google.gdata.data.photos.AlbumEntry;
import com.google.gdata.data.photos.AlbumFeed;
import com.google.gdata.data.photos.PhotoEntry;
import com.google.gdata.data.PlainTextConstruct;
import com.google.gdata.data.Person;
import com.google.gdata.data.media.MediaFileSource;

import java.io.File;
import java.net.URL;



public class main{

private static final String API_PREFIX =
new String("http://picasaweb.google.com/data/feed/api/user/");

public static void main(String[] args){
String user = args[0];
String title = args[1];
String account = args[2];
String passwd = args[3];
String mime = args[4];
int numOfArgs = 5;

try{
// create a new album
URL postUrl = new URL(API_PREFIX + user);

AlbumEntry en = new AlbumEntry();
en.setTitle(new PlainTextConstruct(title));

PicasawebService serv = new PicasawebService("Picasaput");
serv.setUserCredentials(account, passwd);

AlbumEntry insertedEntry = serv.insert(postUrl, en);
AlbumFeed fd = insertedEntry.getFeed();

// upload photos to that album
for(int i=numOfArgs; i<args.length; i++){
MediaFileSource m =
new MediaFileSource(new File(args[i]), mime);
PhotoEntry p = fd.insertPhoto(m);
}

}catch(java.net.MalformedURLException e){
System.out.println(e);
System.exit(1);
}catch(java.io.IOException e){
System.out.println(e);
System.exit(1);
}catch(com.google.gdata.util.AuthenticationException e){
System.out.println(e);
System.exit(1);
}catch(com.google.gdata.util.ServiceException e){
System.out.println(e);
System.exit(1);
}
}
}
java -cp $cp main "$user" "$title" "$account" "$passwd" "$mime" $@