« Explorer for viewing RDF schemas | Main | Reception pictures »

Flickr upload script

I've finally remembered to post the Flickr upload script I used in the recent Flickr uploading festival.

The script takes input in the following format:

path/to/image1.jpg
Title1 (on a single line)
tagA tagB tagC (on a single line)
Paragraph of description, 
terminated by a blank line.

/path/to/image2.jpg
Title2

Paragraph 2.  The above line is an empty line of tags.

The script reads this file from standard input. If you supply the -t switch, the script runs in a test mode and just verifies the existence of each file, printing out the title and tags for the pictures so you can verify that they're correct. (A common error I made is to forget the tags line, which results in the first line of the description being treated as tags.) Without -t, the picture is actually read and uploaded, and the photo ID is printed to standard output.

Pictures will be given your configured default permissions. The script doesn't provide any way to set the photo's permissions or to change the date the photo was taken. If you add either of these features, please send me your patch.

The code started with Michele Campeotto's FlickrUploadr, a PyGTk+-based application. I ripped out all of the GTk+ code and replaced it with the stdin-based interface. The license is GPLv2, because that's the license of the original code.

Comments (2)

Bob Kummerfeld:

One problem with this script (and all the others I can find) is that it reads the file data entirely into memory before appending it to the headers and then sending to the server.

If I want to upload a 100MB file this might be a little memory intensive.

Do you know of example code that does http based file upload but copies the file data to the socket in chunks?

amk:

I haven't seen any such code, either.

If I was trying to get 100Mb onto a server using a script, I would design the server to use HTTP PUT or POST instead of a file upload. Maybe most people do this, and large file uploads therefore aren't needed very much.

About

This page contains a single entry from the blog posted on October 24, 2005 6:48 PM.

The previous post in this blog was Explorer for viewing RDF schemas.

The next post in this blog is Reception pictures.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.31