
Version 13, changed by devbobo@gmail.com. 11/18/2007. Show version history
Because of the way XML works, you can't send binary data as part of an XML request. Instead, you have to encode it using base64 encoding, which increases the size by 25%. So SmugMug provides a variety of upload methods so you can select the best one for your particular application. SmugMug recommends using the HTTP PUT or RAW HTTP POST methods, but that's entirely up to you.
The HTTP spec specifies a method for sending binary files via HTTP called PUT. SmugMug supports HTTP PUT, and it's one of the two preferred methods because the data is entirely passed in binary form, which increases the speed over base64 encoding by 25%.
We'll return an XML formatted response as if you'd made a normal API request for the smugmug.images.upload method, based on the ResponseType given.
The URL for the PUT request consists of both the server you're uploading to (upload.smugmug.com) and the filename of the file you're sending (photo.jpg).
Example: http://upload.smugmug.com/photo.jpg
Since the body of the message is purely the binary data of the image you're adding to SmugMug, you have to send some metadata, such as AlbumID, in the HTTP headers so we know what to do with it. Here are the header fields supported by the HTTP PUT method:
POSTing raw data instead of encoded data is almost identicaly to HTTP PUT, above, except that it uses HTTP POST instead of HTTP PUT.
RAW POST URL: http://upload.smugmug.com/photos/xmlrawadd.mg
Instead of a typical multi-part form encoded POST, with the various necessary variables, including the image data, included in the body, the body only contains the raw binary image data and the rest of the metadata is contained in the headers, just like HTTP PUT.
You can also POST data using a standard multi-part encoded form request. Include each variable as a value in the form data.
MULTI-PART POST URL: http://upload.smugmug.com/photos/xmladd.mg
Just like the HTTP PUT and RAW HTTP POST methods, we'll return an XML formatted response just like if you'd called the smugmug.images.upload API method.
Multi-part binary requests include a "name" element and a "filename" element. We're expecting a non-array for the "name" portion (name it anything you wish), and the full filename, with extension (no path!) for the "filename" portion.
Fields accepted by HTTP POST:
Finally, you can just use the normal XML-RPC and REST smugmug.images.upload calls. Make sure you're using upload.smugmug.com as your endpoint hostname, rather than api.smugmug.com