<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -25,6 +25,7 @@ import httplib, mimetypes
 import hashlib
 import os
 from os import path
+from log import log
 
 version = &quot;1.16&quot;
 # sm_photo_tool offical key:
@@ -342,65 +343,27 @@ class Smugmug:
             message(opts, &quot;%9d: %s\n&quot; % (alb['id'], alb['Title']))
 
     def upload_file(self, albumid, filename, caption=None):
-        fields = []
         data = filename_get_data(filename)
-        fields.append(['ByteCount', str(len(data))])
-        #fields.append(['MD5Sum', md5.new(data).hexdigest()])
-        fields.append(['MD5Sum', hashlib.md5(data).hexdigest()])
-        fields.append(['AlbumID', str(albumid)])
-        fields.append(['SessionID', self.session])
-        fields.append(['ResponseType', 'XML-RPC'])
+
+        # prep HTTP PUT to upload image
+        h = httplib.HTTPConnection(&quot;upload.smugmug.com&quot;)
+        h.connect()
+        h.putrequest('PUT', &quot;/&quot; + filename)
+        h.putheader('Content-Length', str(len(data)))
+        h.putheader('Content-MD5', hashlib.md5(data).hexdigest())
+        h.putheader('X-Smug-SessionID', self.session)
+        h.putheader('X-Smug-Version', '1.2.1')
+        h.putheader('X-Smug-ResponseType', 'Xml-RPC')
+        h.putheader('X-Smug-AlbumID', str(albumid))
+        h.putheader('X-Smug-FileName', filename)
         if caption:
-            fields.append(['Caption', caption])
-
-        file = ['Image', filename, data]
-        self.post_multipart(&quot;upload.smugmug.com&quot;,
-            &quot;/photos/xmladd.mg&quot;, fields, [file])
-
-    def post_multipart(self, host, selector, fields, files):
-        &quot;&quot;&quot;
-        Post fields and files to an http host as multipart/form-data. fields is a
-        sequence of (name, value) elements for regular form fields. files is a
-        sequence of (name, filename, value) elements for data to be uploaded as
-        files. Returns the server's response page.
-        &quot;&quot;&quot;
-        content_type, body = self.encode_multipart_formdata(fields, files)
-        h = httplib.HTTP(host)
-        h.putrequest('POST', selector)
-        h.putheader('content-type', content_type)
-        h.putheader('content-length', str(len(body)))
+            h.putheader('X-Smug-Caption', caption)
         h.endheaders()
-        h.send(body)
-        errcode, errmsg, headers = h.getreply()
-        result = h.file.read()
-        h.close()
-        return result
+        h.send(data)
 
-    def encode_multipart_formdata(self, fields, files):
-        &quot;&quot;&quot;
-        fields is a sequence of (name, value) elements for regular form fields.
-        files is a sequence of (name, filename, value) elements for data to be
-        uploaded as files Return (content_type, body) ready for httplib.HTTP
-        instance
-        &quot;&quot;&quot;
-        BOUNDARY = '----------ThIs_Is_tHe_bouNdaRY_$'
-        CRLF = '\r\n'
-        L = []
-        for (key, value) in fields:
-            L.append('--' + BOUNDARY)
-            L.append('Content-Disposition: form-data; name=&quot;%s&quot;' % key)
-            L.append('')
-            L.append(value)
-        for (key, filename, value) in files:
-            L.append('--' + BOUNDARY)
-            L.append('Content-Disposition: form-data; name=&quot;%s&quot;; filename=&quot;%s&quot;'
-                             % (key, filename))
-            L.append('Content-Type: %s' % get_content_type(filename))
-            L.append(&quot;content-length: %d&quot; % (len(value)))
-            L.append('')
-            L.append(value)
-        L.append('--' + BOUNDARY + '--')
-        L.append('')
-        body = CRLF.join(L)
-        content_type = 'multipart/form-data; boundary=%s' % BOUNDARY
-        return content_type, body
+        # response output
+        resp = h.getresponse()
+        log.debug(&quot;%s: %s&quot; % (resp.status, resp.reason))
+        result = resp.read()
+        h.close()
+        print(&quot;PUT: result: %s&quot; % result)</diff>
      <filename>src/sm_wrapper.py</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>fbaf96c1ec64b65c91b75e1b01dab53866ba3cfb</id>
    </parent>
  </parents>
  <author>
    <name>jesus m rodriguez</name>
    <email>jesusr@redhat.com</email>
  </author>
  <url>http://github.com/jmrodri/sm-photo-tool/commit/546d13d0b4f000a36ce55ab5a5ba0e6a4ec0a1fa</url>
  <id>546d13d0b4f000a36ce55ab5a5ba0e6a4ec0a1fa</id>
  <committed-date>2009-10-30T18:26:25-07:00</committed-date>
  <authored-date>2009-10-30T18:26:25-07:00</authored-date>
  <message>switched to using HTTP PUT instead of HTTP POST</message>
  <tree>3b2d9f4fd736acfc92cd7ca62f67ca529cad0a3b</tree>
  <committer>
    <name>jesus m rodriguez</name>
    <email>jesusr@redhat.com</email>
  </committer>
</commit>
