Uploading image using multipart form data question

dladodlado Registered Users Posts: 11 Big grins
Hi David,

I have a question regarding uploading photos.

I sow in the API that you have the posibility to upload photos using the endpoint http://upload.smugmug.com/photos/xmladd.mg that use multipart form data.

I saw the parameters and it seems that oAuth is not allowed, isn't it ? receives the SessionID

do you have any example of the post data I have to send??

Not only for Multipart but also for Raw HTTP Post or HTTP put.

Thanks in advance!

Damian Lado

Comments

  • devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited April 14, 2010
    Hey Damian,

    Yes, at this point, we don't support OAuth for multi-part POST.

    Here's a simple example of both a raw POST and PUT using OAuth in javascript...

    Raw POST
    var xmlhttp=new XMLHttpRequest();
    xmlhttp.open("POST", "http://upload.smugmug.com/photos/xmlrawadd.mg", false);
    xmlhttp.setRequestHeader('Content-Length', '<filesize in bytes>');
    xmlhttp.setRequestHeader('Content-MD5', '<MD5 of file>');
    xmlhttp.setRequestHeader('Authorization', 'OAuth oauth_consumer_key="..." oauth_signature_method="..." oauth_nonce="..." oauth_signature="..." oauth_timestamp="..." oauth_version="..."');
    xmlhttp.setRequestHeader('X-Smug-AlbumID', '1234');
    xmlhttp.setRequestHeader('X-Smug-FileName', 'photo.jpg');
    xmlhttp.setRequestHeader('X-Smug-ResponseType', 'JSON');
    xmlhttp.setRequestHeader('X-Smug-Version', '1.2.2');
    xmlhttp.send(<image data>);
    

    PUT
    var xmlhttp=new XMLHttpRequest();
    xmlhttp.open("PUT", "http://upload.smugmug.com/photo.jpg", false);
    xmlhttp.setRequestHeader('Content-Length', '<filesize in bytes>');
    xmlhttp.setRequestHeader('Content-MD5', '<MD5 of file>');
    xmlhttp.setRequestHeader('Authorization', 'OAuth oauth_consumer_key="..." oauth_signature_method="..." oauth_nonce="..." oauth_signature="..." oauth_timestamp="..." oauth_version="..."');
    xmlhttp.setRequestHeader('X-Smug-AlbumID', '1234');
    xmlhttp.setRequestHeader('X-Smug-ResponseType', 'JSON');
    xmlhttp.setRequestHeader('X-Smug-Version', '1.2.2');
    xmlhttp.send(<image data>);
    

    Let me know if you have any questions.

    Cheers,

    David
    David Parry
    SmugMug API Developer
    My Photos
Sign In or Register to comment.