Options

Can't upload images with updated API

tiun.hltiun.hl Registered Users Posts: 6 Big grins
edited September 20, 2011 in SmugMug API Support & Integrations
Hi,

Since the "smugmug.images.upload" method has been deprecated I rewrote my Perl script for uploading.

Withe the new code, I found that small images(53KB) can successfully upload but not larger ones (like 1.3MB).
use File::Slurp;
use HTTP::Request::Common;

.........

      my $image = read_file($path, binmode => ':raw');
      $file_size = length($image);
      $imagemd5 = md5_hex $image;

            $upload_ua = LWP::UserAgent->new;
            $upload_ua->cookie_jar({});
            $upload_reply = $upload_ua->request(PUT 'http://upload.smugmug.com/' . $filename,
                'X-Smug-AlbumID' => $albumid,
                'X-Smug-SessionID' => $sessionid,
                'X-Smug-Version' => '1.2.2',
                'X-Smug-FileName' => $filename,
                'Content-MD5' => $imagemd5,
                'Content-Length' => $file_size,
                'X-Smug-ResponseType' => 'JSON',
                Content => $image);
...........


The following is the reply for the small image upload:
 {"stat":"ok","method":"smugmug.images.upload","Image":{"id":1282795082,"Key":"rmSHKdX","URL":"http://tiun.smugmug.com/\u7279\u6b8a\u7684\u65e5\u5b50/110508\u6bcd\u89aa\u7bc0/16956127_mJ3C6g#1282795082_rmSHKdX"}}

The following is the reply for the larger image upload:
{"stat":"fail","code":61,"message":"We're sorry, but that upload got interrupted somewhere along the way.  Please try again."}

The "upload log" in the control panel shows the problem is "incomplete file".

Is there any upload file size limit??? Or what should I modify?

Thanks a lot!!

Comments

  • Options
    devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited May 8, 2011
    G'day Hiun,

    Incomplete file means that we didn't get the full file that we were expecting.

    Let me outline an example...

    You attempted to upload a file DSC_0462.jpg, the reported Content-Length was 1333098 bytes, but the file we received was only 66243 bytes in length. This typically means that the connection got close prematurely.

    Hope this helps.

    David
    David Parry
    SmugMug API Developer
    My Photos
  • Options
    Jeffrey FriedlJeffrey Friedl Registered Users Posts: 32 Big grins
    edited May 9, 2011
    devbobo wrote: »
    Incomplete file means that we didn't get the full file that we were expecting.
    David

    I'm getting occasional reports of this from users of my Lightroom plugin. Nothing about the plugin or Lightroom has changed, but I know your backend processing has changed, so that's where I'm guessing the issue lies. But I don't know. What should I tell users when they report it to me?
  • Options
    devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited May 9, 2011
    I'm getting occasional reports of this from users of my Lightroom plugin. Nothing about the plugin or Lightroom has changed, but I know your backend processing has changed, so that's where I'm guessing the issue lies. But I don't know. What should I tell users when they report it to me?

    c'mon jeff, not really show how us not receiving the full file is an issue with our backend, sounds more like a connectivity issue.

    have any users who are experiencing this issue contact the helpdesk, mark it my attention if they want.
    David Parry
    SmugMug API Developer
    My Photos
  • Options
    devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited May 9, 2011
    I'm getting occasional reports of this from users of my Lightroom plugin. Nothing about the plugin or Lightroom has changed, but I know your backend processing has changed, so that's where I'm guessing the issue lies. But I don't know. What should I tell users when they report it to me?

    Also, to put the error rate in perspective, over the last 7 days, your uploader has uploaded 178,728 images of which 398 failed. I'll let you do the math on that. thumb.gif
    David Parry
    SmugMug API Developer
    My Photos
  • Options
    tiun.hltiun.hl Registered Users Posts: 6 Big grins
    edited May 9, 2011
    Hi David,

    Using HTTP::Request instead of "HTTP::Request::Common" fix this problem.
                my $upload_ua = LWP::UserAgent->new;
                my $upload_request = HTTP::Request->new(POST => 'http://upload.smugmug.com/');
                $upload_request->header('X-Smug-AlbumID' => $albumid);
                $upload_request->header('X-Smug-SessionID' => $sessionid);
                $upload_request->header('X-Smug-Version' => '1.2.0');
                $upload_request->header('X-Smug-FileName' => $filename);
                $upload_request->header('Content-MD5' => $imagemd5);
                $upload_request->header('Content-Length' => $file_size);
                $upload_request->header('X-Smug-ResponseType' => 'JSON');
                $upload_request->content($image);
                my $upload_reply = $upload_ua->request($upload_request);
    

    Thanks for your help!
    devbobo wrote: »
    G'day Hiun,

    Incomplete file means that we didn't get the full file that we were expecting.

    Let me outline an example...

    You attempted to upload a file DSC_0462.jpg, the reported Content-Length was 1333098 bytes, but the file we received was only 66243 bytes in length. This typically means that the connection got close prematurely.

    Hope this helps.

    David
  • Options
    HyperblueHyperblue Registered Users Posts: 1 Beginner grinner
    edited September 20, 2011
    Hi Tiun,

    I saw you post in the forums that you had a Perl script for uploading images to SmugMug. I have been struggling with modifying Marco's Gallery 2 Uploader and have had no success.

    I tried to find your script, but the link is dead: http://www.warrenc.com/blog/ezsmugup

    Do you have a new link for your script? I would really appreciate it!
    tiun.hl wrote: »
    Hi David,

    Using HTTP::Request instead of "HTTP::Request::Common" fix this problem.
                my $upload_ua = LWP::UserAgent->new;
                my $upload_request = HTTP::Request->new(POST => 'http://upload.smugmug.com/');
                $upload_request->header('X-Smug-AlbumID' => $albumid);
                $upload_request->header('X-Smug-SessionID' => $sessionid);
                $upload_request->header('X-Smug-Version' => '1.2.0');
                $upload_request->header('X-Smug-FileName' => $filename);
                $upload_request->header('Content-MD5' => $imagemd5);
                $upload_request->header('Content-Length' => $file_size);
                $upload_request->header('X-Smug-ResponseType' => 'JSON');
                $upload_request->content($image);
                my $upload_reply = $upload_ua->request($upload_request);
    
    Thanks for your help!
Sign In or Register to comment.