I’ve been trying to figure out why my image upload to smugmug using HTTP PUT wasn’t working for quite some time. I always got a “connection closed” error. After looking at this example more closely I finally realized what my problem was. I forgot the freakin slash. The upload url is supposed to be http://upload.smugmug.com/filename. My code looked like this:
conn = httplib.HTTPConnection("upload.smugmug.com", 80)
conn.connect()
conn.request("PUT", filename, data, headers)

This obviously generates the following url: http://upload.smugmug.comXXX where XXX is the value of filename. That’s just outright wrong. SIGH! But I fixed it and now my uploads work. Here’s the working snippet:
conn = httplib.HTTPConnection("upload.smugmug.com", 80)
conn.connect()
conn.request("PUT", '/' + filename, data, headers)

Now I can get back to finishing my XMLRPC to JSON migration of sm-photo-tool.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s