413 Request Entity Too Large (from upload server)

TerenceKearns.comTerenceKearns.com Registered Users Posts: 13 Big grins
When attempting to connect for a file upload using the API, has anyone received the following http response back from the upload server?

[HTML]
<title>413 Request Entity Too Large</title>
</head><body>
<h1>Request Entity Too Large</h1>
The requested resource<br />/photos/xmlrawadd.mg<br />
does not allow request data with PUT requests, or the amount of data provided in
the request exceeds the capacity limit.
</body>
[/HTML]

Here is a snippet of PHP code I am using to connect.

[PHP]
$data = array("name" => "the file", "file" => "@".$ImgFile);
$arrHeaders = array();
$arrHeaders[] = "Content-MD5: ".md5_file($ImgFile);
$arrHeaders[] = "Content-length: ".filesize($ImgFile);
$arrHeaders[] = "X-Smug-SessionID: ".$this->sid;
$arrHeaders[] = "X-Smug-Version: ".API_VERSION;
$arrHeaders[] = "X-Smug-ResponseType: PHP";
$arrHeaders[] = "X-Smug-AlbumID: ".$this->aid;
$arrHeaders[] = "X-Smug-FileName: ".basename($ImgFile);
$arrHeaders[] = "X-Smug-Keywords: ".$argKeyWords;
$cl = curl_init(RAW_UPLOAD_URL)
OR $this->log->error("Could not initiate image upload.");
curl_setopt($cl,CURLOPT_USERAGENT,SMUG_USER_AGENT);
curl_setopt($cl,CURLOPT_RETURNTRANSFER,1);
curl_setopt($cl,CURLOPT_HTTPHEADER,$arrHeaders);
curl_setopt($cl,CURLOPT_POST,1);
curl_setopt($cl,CURLOPT_POSTFIELDS,$data);
$fp=fopen($ImgFile,"r");
curl_setopt($cl,CURLOPT_INFILE,$fp);
curl_setopt($cl,CURLOPT_INFILESIZE,filesize($ImgFile));
curl_setopt($cl,CURLOPT_UPLOAD,1);
$res = curl_exec($cl);
fclose($fp);
curl_close($cl);
[/PHP]

The whole lot is in a try/catch block and no exception is being thrown.

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

The size of the image that the test script is attempting to upload is about 100kb.

Comments

  • devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited June 7, 2010
    G'day Terence,

    Thanks, got your script...but I haven't had a chance to play with it yet, I've been moving house.

    Hoping to get to it sometime this week.

    Cheers,

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