Problem uploading using Python code

gat1234gat1234 Beginner grinnerPosts: 3Registered Users Beginner grinner
I have a Python script that used to work just fine to upload photos and videos. It uses the 1.2.0 API and the RAW HTTP POST method. Unfortunately, for the last couple of weeks it fails consistently with the following JSON response:

{"stat":"fail","code":5,"message":"system error (nofiles)"}

Nothing is showing up in the upload log on SmugMug.

Nothing has changed on my end so it seems like something changed at SmugMug. Any idea how I can get this working again? I can provide some sample code if necessary.

I have no trouble uploading using the Java applet.

Thanks!

Comments

  • justinjustin Beginner grinner Posts: 1Registered Users Beginner grinner
    edited July 12, 2010
    Same Issue
    I'm having the same issue. I sent an email to Smug Mug. The response said that they were passing my email off to one of the Developers, but I haven't heard anything back yet.
  • knykny Big grins Posts: 33Registered Users Big grins
    edited July 13, 2010
    gat1234 wrote: »
    I have a Python script that used to work just fine to upload photos and videos. It uses the 1.2.0 API and the RAW HTTP POST method. Unfortunately, for the last couple of weeks it fails consistently with the following JSON response:

    {"stat":"fail","code":5,"message":"system error (nofiles)"}

    Nothing is showing up in the upload log on SmugMug.

    Nothing has changed on my end so it seems like something changed at SmugMug. Any idea how I can get this working again? I can provide some sample code if necessary.

    I have no trouble uploading using the Java applet.

    Thanks!

    Same issue here. I am using a python upload script based off of the example here:
    http://scottmoonen.com/tag/smugmug-python-upload-picture-image-gallery-script-api/
  • richWrichW SmugMug QA Southern CaliforniaPosts: 2,558Registered Users Major grins
    edited July 13, 2010
    justin wrote: »
    I'm having the same issue. I sent an email to Smug Mug. The response said that they were passing my email off to one of the Developers, but I haven't heard anything back yet.
    I'll ask the engineer who works with the API to take a look at this for you. I have some info at the help desk I received from a couple of you and I'll forward over to the engineer.
  • alphamonkeyalphamonkey Beginner grinner Posts: 2Registered Users Beginner grinner
    edited July 15, 2010
    There is a Pymug bug filed on the error as well. The problem seems to be specific to the HTTP POST method. Rich, can you post here if you find a solution?
  • knykny Big grins Posts: 33Registered Users Big grins
    edited July 16, 2010
    richW wrote: »
    I'll ask the engineer who works with the API to take a look at this for you. I have some info at the help desk I received from a couple of you and I'll forward over to the engineer.

    Can we get an update or at least an acknowledgement that this is being addressed.

    I am getting a large backlog of photos. My business depends on this python script to upload photos with keyword information included (a separate app browses photos locally and assigns keyword as prep for automated upload by python script) to enable search interface to show appropriate pics. With this functionality not working I am stuck unable to load photos from recent events. Please confirm this is being looked at.
  • devbobodevbobo LR whisperer Melbourne, AUPosts: 4,335Administrators SmugMug Employee
    edited July 16, 2010
    This problem is a script issue. Uploads are posted to upload.smugmug.com/photos/xmlrawadd.mg which is a raw post method. The script is sending the Content-Type header to set to 'application/x-www-form-urlencoded'. I'm not quite sure what this is doing on a http packet level, but it was causing HTTPScoop to crash.

    Users can easily resolve this issue by adding the following line of code ('Content-Type': 'none')...
      upload_request = urllib2.Request(UPLOAD_URL,
                                       data,
                                       {'Content-Length'  : len(data),
                                        'Content-MD5'     : hashlib.md5(data).hexdigest(),
                                        'Content-Type'     : 'none',
                                        'X-Smug-SessionID': session,
                                        'X-Smug-Version'  : API_VERSION,
    				    'X-Smug-ResponseType' : 'JSON',
    				    'X-Smug-AlbumID'  : album_id,
    				    'X-Smug-FileName' : filename })
    

    I'd like to note that issues relating to 3rd apps are the responsibility of the developer and not SmugMug. While SmugMug is happy to help out as always, technical resources may not be available at the drop of a hat.

    Cheers,

    David
    David Parry
    SmugMug API Developer
    My Photos
  • alphamonkeyalphamonkey Beginner grinner Posts: 2Registered Users Beginner grinner
    edited July 17, 2010
    devbobo wrote: »
    This problem is a script issue. Uploads are posted to upload.smugmug.com/photos/xmlrawadd.mg which is a raw post method. The script is sending the Content-Type header to set to 'application/x-www-form-urlencoded'. I'm not quite sure what this is doing on a http packet level, but it was causing HTTPScoop to crash.

    Users can easily resolve this issue by adding the following line of code ('Content-Type': 'none')...
      upload_request = urllib2.Request(UPLOAD_URL,
                                       data,
                                       {'Content-Length'  : len(data),
                                        'Content-MD5'     : hashlib.md5(data).hexdigest(),
                                        'Content-Type'     : 'none',
                                        'X-Smug-SessionID': session,
                                        'X-Smug-Version'  : API_VERSION,
    				    'X-Smug-ResponseType' : 'JSON',
    				    'X-Smug-AlbumID'  : album_id,
    				    'X-Smug-FileName' : filename })
    

    I'd like to note that issues relating to 3rd apps are the responsibility of the developer and not SmugMug. While SmugMug is happy to help out as always, technical resources may not be available at the drop of a hat.

    Cheers,

    David

    Thanks David!

    I've updated pymug accordingly (diff)

    Would you mind updating the documentation for the "RAW HTTP Post method" to note the Content-Type: 'none' restriction? I'm not trying to be argumentative, but I do feel this is an API change.
  • nzsnappernzsnapper Big grins Posts: 34Registered Users Big grins
    edited July 18, 2010
    Still problems with replacing images
    I have updated my Aperture plugin to set the content-type to none (previously it set image/jpeg) but one of my users is still getting errors on replace, upload seems fine apparently but he is getting failures:

    2010/07/17 21:23:39 WARN +[RLSmugMugImage uploadImage:replaceExisting:forSession:andError:] <> - Image upload failed {
    code = 4;
    message = "wrong format ()";
    method = "smugmug.images.replace";
    stat = fail;
    }

    the full headers for the posted images are as follows:

    2010/07/17 21:23:39 WARN -[RLSmugMugRequestMethodHelper uploadImageSynchronousRequest:replaceExisting:withArguments:error:] <> - Upload failed header fields : {
    "Content-Length" = 2667078;
    "Content-Md5" = 4c324364ddefece453add096656b15a9;
    "Content-Type" = none;
    "User-Agent" = "SmuginPro/1.1";
    "X-Smug-Albumid" = 12680086;
    "X-Smug-Caption" = "2009-12-29%20-%20Elk%20Sled%20Ride%20-%20007";
    "X-Smug-Filename" = "2009-12-29%20-%20Elk%20Sled%20Ride%20-%20007.jpeg";
    "X-Smug-Imageid" = 933566263;
    "X-Smug-Keywords" = "Annalisa,Idaho,April,Tilmant,2009,SmuginProForAperture";
    "X-Smug-Responsetype" = JSON;
    "X-Smug-Sessionid" = 0cdbb4bd3eba7e5b0578c96dd7fafc7d;
    "X-Smug-Version" = "1.2.2";
    }

    I don't understand why one user can have issues and others not.
  • nzsnappernzsnapper Big grins Posts: 34Registered Users Big grins
    edited July 18, 2010
    And now it may be working again...
  • devbobodevbobo LR whisperer Melbourne, AUPosts: 4,335Administrators SmugMug Employee
    edited July 18, 2010
    Would you mind updating the documentation for the "RAW HTTP Post method" to note the Content-Type: 'none' restriction? I'm not trying to be argumentative, but I do feel this is an API change.

    For clarification, we don't specifically need the Content-Type set to none. For some reason, python defaults to a Content-Type of 'application/x-www-form-urlencoded' for POST. I've written a lot of uploading code in default languages and never experienced this before.

    So in this case, setting the Content-Type to none is the only way to stop python from being stupid.
    David Parry
    SmugMug API Developer
    My Photos
  • knykny Big grins Posts: 33Registered Users Big grins
    edited July 19, 2010
    devbobo wrote: »
    For clarification, we don't specifically need the Content-Type set to none. For some reason, python defaults to a Content-Type of 'application/x-www-form-urlencoded' for POST. I've written a lot of uploading code in default languages and never experienced this before.

    So in this case, setting the Content-Type to none is the only way to stop python from being stupid.

    Success! Thanks for the info about the content-type.

    fwiw, my script has been running as-is without issue for 16 months, so something on smugmug's end has changed. I don't think this can be fully blamed on python.

    Appreciate this being looked into.
  • nzsnappernzsnapper Big grins Posts: 34Registered Users Big grins
    edited July 19, 2010
    One of my users is still having issues, still only with the replace case. If he replaces 10 images it seems fine but if he tries to replace 15 or so it fails. Right now I don't see anything wrong with the plugin, the issue appears to be specific to one user, he has no problems with uplad only when replacing. The debug log for the success is as follows:

    2010/07/18 11:25:38 DEBUG -[RLSmugMugRequestMethodHelper uploadImageSynchronousRequest:replaceExisting:withArguments:error:] <> - Header fields : {
    "Content-Length" = 2569212;
    "Content-Md5" = 20797218b1ff89b0190bf7ae3c4841da;
    "Content-Type" = none;
    "User-Agent" = "SmuginPro/1.1";
    "X-Smug-Albumid" = 12680086;
    "X-Smug-Caption" = "2009-12-29%20-%20Elk%20Sled%20Ride%20-%20009";
    "X-Smug-Filename" = "2009-12-29%20-%20Elk%20Sled%20Ride%20-%20009.jpeg";
    "X-Smug-Imageid" = 933566458;
    "X-Smug-Keywords" = "Alan,Idaho,Tilmant,2009";
    "X-Smug-Responsetype" = JSON;
    "X-Smug-Sessionid" = a71bc7248506f9d2277af6ceacaf8c49;
    "X-Smug-Version" = "1.2.2";
    }
    2010/07/18 11:25:49 DEBUG -[RLSmugMugRequestMethodHelper connection:didReceiveResponse:] <> - Received response <NSHTTPURLResponse: 0x2b90bcb0>
    2010/07/18 11:25:49 DEBUG -[RLSmugMugRequestMethodHelper connectionDidFinishLoading:] <> - JSON: {
    Image = {
    Key = udPS8;
    URL = "http://photos.tilmant.com/Family/All-Photos/12680086_qecLu#933566458_udPS8";
    id = 933566458;
    };
    method = "smugmug.images.replace";
    stat = ok;
    }

    and for the failure case

    2010/07/18 11:26:54 DEBUG -[RLSmugMugRequestMethodHelper uploadImageSynchronousRequest:replaceExisting:withArguments:error:] <> - Header fields : {
    "Content-Length" = 1735212;
    "Content-Md5" = 8e221eed4542cd2a530ff1a4e5cbe466;
    "Content-Type" = none;
    "User-Agent" = "SmuginPro/1.1";
    "X-Smug-Albumid" = 12680086;
    "X-Smug-Caption" = "2009-12-29%20-%20Elk%20Sled%20Ride%20-%20020";
    "X-Smug-Filename" = "2009-12-29%20-%20Elk%20Sled%20Ride%20-%20020.jpeg";
    "X-Smug-Imageid" = 933567602;
    "X-Smug-Keywords" = "Tilmant,Tom,2009,Idaho,Bette,Merle,Reid,Gene,Lisa";
    "X-Smug-Responsetype" = JSON;
    "X-Smug-Sessionid" = 42b7b96260fa09d5eb2b85305263df34;
    "X-Smug-Version" = "1.2.2";
    }
    2010/07/18 11:27:39 DEBUG -[RLSmugMugRequestMethodHelper connection:didReceiveResponse:] <> - Received response <NSHTTPURLResponse: 0x3f76da30>
    2010/07/18 11:27:39 INFO -[RLSmugmugResponse initWithDictionary:] <> - Request failed : {
    code = 4;
    message = "wrong format ()";
    method = "smugmug.images.replace";
    stat = fail;
    }

    Once it has failed it continues to fail for any subsequent images.

    Any ideas would be appreciated.
Sign In or Register to comment.