• Gear
  • Shots
  • Photo Craft
  • Video
  • Wide Angle
  • Support
  • New Stuff
  • More
Support SmugMug APIs, Hacks & Tricks "Expired timestamp" response I receive when I upload a big video file using API

FAQtoid

Ever wanted to create an Avatar? Creating an Avatar!

Searching Dgrin with Google Searching with Google

Dgrin Challenges

Congratulations to the Winner of DSS #128 (Sunrise or Sunset), ShootingStar.

The next Dgrin Challenge DSS #129 (Silhouette Revisited ) is open for entries through May 27th, 2013 at 8:00pm PDT.

As always, we look forward to your participation but please do take a moment to read through the rules before posting your entry.

Past DSS Challenge Winners, DSS Challenge Rules, and other important DSS Challenge information is here.

Need some help with Accessories?

Tutorials

Ever find yourself wondering just how someone managed to create an image using different effects?

Here are three simple tutorials we hope will encourage you to try something new.

The Hot Seat

A lifelong interest in landscape photography has led Eyal Oren to make a study of his adopted hometown of Marblehead, MA. As you can see, his dedication is paying off!

Africa!

Dgrinners Harryb, Pathfinder, and others joined Andy Williams and Marc Muench on Safari in East Africa recently. Here are some awesome threads to check out!

 
Thread Tools Display Modes
Old Oct-15-2012, 10:44 AM
#1
sujit1779 is offline sujit1779 OP
Big grins
"Expired timestamp" response I receive when I upload a big video file using API
Hi,

I was uploading a big video file, 25 MB using API and I received this response (error)

{
"STAT": "FAIL",
"METHOD": "SMUGMUG.IMAGES.UPLOAD",
"CODE": 30,
"MESSAGE": "EXPIRED TIMESTAMP"
}

upload took almost 30 mins and thats why I think timestamp might expire.

What should I do in cases where upload takes a long time, how can I get rid of this error.

Thanks.
Old Oct-16-2012, 03:09 PM
#2
devbobo is offline devbobo
technicolored
devbobo's Avatar
G'day,

For uploads, we validate against the time the connection was opened rather than the time that the upload finished for this very reason.

I can verify that we have lots of long video uploads with our LR plugin that would have expired if we used the time the upload finished.

Please double check that your date/time is correct. For the LR plugin, we use the 'Date' response header to compare against the sent oauth_timestamp to automatically adjust the future oauth_timestamps. It's a method that works well to prevent those sort of errors, you might find it useful as well.

Cheers,

David
__________________
David Parry
SmugMug API Developer
My Photos
Old Oct-18-2012, 12:22 AM
#3
sujit1779 is offline sujit1779 OP
Big grins
Quote:
Originally Posted by devbobo View Post
G'day,

For uploads, we validate against the time the connection was opened rather than the time that the upload finished for this very reason.

I can verify that we have lots of long video uploads with our LR plugin that would have expired if we used the time the upload finished.

Please double check that your date/time is correct. For the LR plugin, we use the 'Date' response header to compare against the sent oauth_timestamp to automatically adjust the future oauth_timestamps. It's a method that works well to prevent those sort of errors, you might find it useful as well.

Cheers,

David
Thanks David for the reply. What I am doing in my code is that I am writing in parts (i.e chunks), so is it possible that when the last part gets written timestamp gets expired? Below is my code for your reference

Uri url = new Uri("http://upload.smugmug.com/");
string timeStamp = base2.GenerateTimeStamp();
string nonce = base2.GenerateNonce();
base2.includeVersion = true;
string str5 = base2.GenerateSignature(url, this.Smugmug_CONSUMER_KEY, this.Smugmug_CONSUMER_SECRET, this.SmugmugAuthToken, this.SmugmugAuthSecret, "POST", timeStamp, nonce, OAuth.OAuthBase.SignatureTypes.HMACSHA1, out str, out str2);
byte[] image = System.IO.File.ReadAllBytes(path);
string str6 = this.calculateMD5Hash(image);
int length = image.Length;
request = (HttpWebRequest)WebRequest.Create("http://upload.smugmug.com/");
request.ContentLength = length;
request.Method = "POST";
request.Headers.Add("X-Smug-Pretty", "true");

request.AllowWriteStreamBuffering = false;

request.ContentType = this.ContentType(Path.GetExtension(path));
request.Headers["Content-MD5"] = str6;
request.Headers.Add("Authorization", "OAuth oauth_consumer_key=\"" + this.Smugmug_CONSUMER_KEY + "\",oauth_token=\"" + this.SmugmugAuthToken + "\",oauth_signature_method=\"HMAC-SHA1\",oauth_signature=\"" + HttpUtility.UrlEncode(str5) + "\",oauth_timestamp=\"" + timeStamp + "\",oauth_nonce=\"" + nonce + "\", oauth_version=\"1.0\"");
request.Headers.Add("X-Smug-Version", "1.2.0");
request.Headers.Add("X-Smug-ResponseType", "JSON");
request.Headers.Add("X-Smug-AlbumID", albumId);
request.Headers.Add("X-Smug-FileName", Path.GetFileName(path));


requestStream = request.GetRequestStream();

int start = 0;
int chunkSize = 1024 * 100;
try
{
while (start <= length)
{
if (start + chunkSize > length)
requestStream.Write(image, start, length-start);
else
requestStream.Write(image, start,chunkSize);
start += chunkSize;
double percentage = ((start) / (length * 1.0) ) * 100 ;
Console.WriteLine("uploading: " + percentage.ToString() + "%");
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}

response = (HttpWebResponse)request.GetResponse();

reader = new StreamReader(response.GetResponseStream());
string strResult = reader.ReadToEnd().ToUpper();
Console.WriteLine(DateTime.Now.ToString() + "smugmug >> " + strResult);
if (strResult.Contains("OK") && strResult.Contains("STAT") && strResult.Contains("METHOD") && strResult.Contains("SMUGMUG.IMAGES.UPLOAD"))
flag = strResult;
else
flag = "";
Console.WriteLine(DateTime.Now.ToString() + "smugmug UPLOAD in seconds " + DateTime.Now.Subtract(dtS).TotalSeconds.ToString() );

response = (HttpWebResponse)request.GetResponse();

reader = new StreamReader(response.GetResponseStream());
string strResult = reader.ReadToEnd().ToUpper();
Console.WriteLine(DateTime.Now.ToString() + "smugmug >> " + strResult);
if (strResult.Contains("OK") && strResult.Contains("STAT") && strResult.Contains("METHOD") && strResult.Contains("SMUGMUG.IMAGES.UPLOAD"))
flag = strResult;
else
flag = "";
Console.WriteLine(DateTime.Now.ToString() + "smugmug UPLOAD in seconds " + DateTime.Now.Subtract(dtS).TotalSeconds.ToString() );

Thanks.
Tell The World!  
Similar Threads Thread Starter Forum Replies Last Post
File Upload Support requested Zosos SmugMug Support 1 Nov-05-2006 10:22 AM
8 Megabytes per file (Video questsions / request) gooseattack SmugMug Support 2 Jun-23-2005 11:54 AM


Thread Tools
Display Modes

Posting Rules  
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump