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)
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?
Posted by Bob Kummerfeld | October 24, 2005 11:50 PM
Posted on October 24, 2005 23:50
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.
Posted by amk | October 25, 2005 10:17 AM
Posted on October 25, 2005 10:17