stuck on smugmug.images.upload API call

crennercrenner Registered Users Posts: 33 Big grins
I'm working on my basetosmug application (VB6 based pbase.com gallery to smugmug.com album conversion tool).

I've written a large portion of the application, but now I am stuck, and don't know how to upload images via the API.

I do not understand how to call the smugmug.images.upload API method.

The documentation I can find is in 2 locations:
1) http://smugmug.com/hack/method-smugmug.images.upload (API method documentation for smugmug.images.upload)
2) http://smugmug.com/hack/xmlrpc-post (how to upload VIA POST)

The first document above warns of problems with uploading images via XML-RPC (which I am not using, I am using REST instead), and gives an outline of the variables expected by the API method. The documentation seems to be more focused on XML-RPC, than on REST.

The second document above also appears also to be focused on XML-RPC users (and not those that are using REST like me).

I am an experienced VB programmer. I am NOT an experienced XML programmer.

So far basetosmug uses:
VisualBasic6 (SP6)
WinHTTP (for requesting html pages and images from pbase)
MSXML (for requesting and parsing XML data from the smugmug API using REST)
DAO (for reading/writing Microsoft Access databases - which I am using as a placeholder for pbase data before uploading to smugmug)

This leaves me with the following problems:
1) I'm not sure which URI to send my images to (since I am using REST):
a) http://api.SmugMug.com/hack/rest/ (used for HTTP GET requests to the smugmug API using REST)
b) http://upload.SmugMug.com/hack/rest/ (supposed to be used for HTTP POSTing to the smugmug API using REST)
c) http://upload.SmugMug.com/photos/xmladd.mg (supposed to be used for sending multi-part encoded HTTP POSTs via XML-RPC)
d) http://upload.smugmug.com/hack/xmlrpc/ (supposed to be used for HTTP POSTing to the smugmug API of images using XML-RPC)

2) I'm having trouble finding documenation for sending multi-part encoded POSTs via VB6 (with or without WinHTTP or MSXML)

3) I'm having trouble finding documentation for sending Base64 encoded data in a HTTP POST via VB6 (with or without WinHTTP or MSXML)

So I guess it boils down to the following questions to help me figure out how to use the smugmug API method for uploading images in VB6:
1) Do I need to use HTTP POST (instead of HTTP GET for this API method)? (I believe so, but am unsure)
2) Which URI should I use? (my guess is http://upload.SmugMug.com/hack/rest/)
3) Which encoding should I use? (my guess is base64)
4) How do I easily implement multi-part or base64 encoding in my VB6 application (keep in mind, I might want/need to distribute this application to other pbase and smugmug users, so I need to be aware of licensing, platform, and distribution restrictions)?
5) How do I construct my HTTP POST in VB6 to include the binary image (as well as the other variables, of course) using WinHTTP, XMLHTTP, ServerXMLHTTP request (or other means)?

Also, is there additional smugmug API documentation/examples/etc., other than that at http://smugmug.com/hack ?

Comments

  • devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited September 4, 2006
    Hey Dude,

    Sorry i am in training today, hopefully I will get a chance to reply tonight.

    Cheers,

    David
    David Parry
    SmugMug API Developer
    My Photos
  • crennercrenner Registered Users Posts: 33 Big grins
    edited September 4, 2006
    Thanks!
    devbobo wrote:
    Sorry i am in training today, hopefully I will get a chance to reply tonight.

    Thanks! I'm still working on figuring it out myself (I'm too stuborn to give up), but I'll take all the help I can get!
  • onethumbonethumb Administrators Posts: 1,269 Major grins
    edited September 4, 2006
    crenner wrote:
    So I guess it boils down to the following questions to help me figure out how to use the smugmug API method for uploading images in VB6:
    1) Do I need to use HTTP POST (instead of HTTP GET for this API method)? (I believe so, but am unsure)

    Yep, you use HTTP POST to send to http://upload.smugmug.com/photos/xmladd.mg

    Alternatively, if you want to get really creative and save 25% in size (and thus reduce upload time), you can use the newly released but unpublished:

    http://upload.smugmug.com/photos/xmlrawadd.mg

    It's in production use by a few apps, so it's safe to use, I just haven't documented it yet. If you'd like to be a guinea pig, it's pretty easy. You get to skip the base64 encoding. Basically, you send the other variables as HTTP headers instead of POST form variables.

    Make sure you set 'ResponseType' to 'REST' if you want REST replies back, either way. Other than that, it's identical to XML-RPC.
    crenner wrote:
    3) Which encoding should I use? (my guess is base64)

    If you use http://upload.smugmug.com/photos/xmladd.mg , you need to use base64 encoding for the binary portion, and make sure everything else conforms to multi-part form encoding.
    crenner wrote:
    4) How do I easily implement multi-part or base64 encoding in my VB6 application (keep in mind, I might want/need to distribute this application to other pbase and smugmug users, so I need to be aware of licensing, platform, and distribution restrictions)?
    5) How do I construct my HTTP POST in VB6 to include the binary image (as well as the other variables, of course) using WinHTTP, XMLHTTP, ServerXMLHTTP request (or other means)?

    I'll keep an eye on this thread to see what's going on, and I'll see if I can whip up some examples or something.

    Thanks,

    Don
  • crennercrenner Registered Users Posts: 33 Big grins
    edited September 5, 2006
    basetosmug working!!!
    First and foremost, thank you for the fast replies.

    Second, (and pretty importantly) basetosmug is now working!!! Please see the following post for details: http://www.dgrin.com/showthread.php?p=378336#post378336

    I'm not sure I can explain how I did it (without posting source), but here is the gist:

    1) I sent most of the variables via the URL (conforms with REST nicely that way)
    2) I sent the binary data in multi-part encoding
    3) I liberally used and adapted sample code for posting binary data in multipart format (designed for Windows Scripting using VBS) from the following two URIs (written by Antonin Foller, PSTRUH Software):
    a) http://www.motobit.com/tips/detpg_uploadvbsie/
    b) http://www.motobit.com/tips/detpg_post-binary-data-url/

    It needs work, but it gets the job done!
  • devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited September 5, 2006
    sweet thumb.gif

    the method you linked to is basically, the same as I use for javascript.
    David Parry
    SmugMug API Developer
    My Photos
Sign In or Register to comment.