• Gear
  • Shots
  • Photo Craft
  • Video
  • Wide Angle
  • Support
  • New Stuff
  • More
Support SmugMug APIs, Hacks & Tricks "underlying connection was closed: The connection was closed unexpectedly" big file

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 Apr-26-2012, 01:57 PM
#1
sujit1779 is offline sujit1779 OP
Big grins
"underlying connection was closed: The connection was closed unexpectedly" big file
Hi,
When I try to upload image file around 10 MB, I get this error
"underlying connection was closed: The connection was closed unexpectedly"

Below is my code, can anyone help me out?

=================================
HttpWebResponse response = null;
HttpWebRequest request = null;
Stream str = null;
bool error = false;
StreamReader sr = null;

OAuth.OAuthBase myOAuth = new OAuth.OAuthBase();
string normalizedUrl;
string normalizedRequestParameters;
Uri uri = new Uri("http://upload.smugmug.com/" + Path.GetFileName(path));

string timeStamp = myOAuth.GenerateTimeStamp();
string nonce = myOAuth.GenerateNonce();
myOAuth.includeVersion = true;

string signature = myOAuth.GenerateSignature(uri, Smugmug_CONSUMER_KEY, Smugmug_CONSUMER_SECRET, SmugmugAuthToken
, SmugmugAuthSecret, "PUT", timeStamp, nonce, OAuth.OAuthBase.SignatureTypes.HMACSHA1,
out normalizedUrl, out normalizedRequestParameters);



// string path = @"K:\pics and video\New folder\DSC02235.JPG";
byte[] image = System.IO.File.ReadAllBytes(path);

string hash = calculateMD5Hash(image);
int size = image.Length;

request = (HttpWebRequest)WebRequest.Create("http://upload.smugmug.com/" + Path.GetFileName(path));
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Ssl3;
request.Method = "PUT";
request.ContentLength = size;
request.Timeout = 2147483647;
request.ReadWriteTimeout = 2147483647;
request.ContentType = ContentType(Path.GetExtension(path));

request.Headers["Content-MD5"] = hash;
request.Headers.Add("Authorization", "OAuth oauth_consumer_key=\"" + Smugmug_CONSUMER_KEY + "\",oauth_token=\"" + SmugmugAuthToken
+ "\",oauth_signature_method=\"HMAC-SHA1\",oauth_signature=\"" + HttpUtility.UrlEncode(signature) + "\",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));

request.Headers.Add("Content-Length", size.ToString());

str = request.GetRequestStream();
str.Write(image, 0, size);
str.Flush();
str.Close();

response = (HttpWebResponse)request.GetResponse();
sr = new StreamReader(response.GetResponseStream());

}
=================================
Thanks.
Old Apr-26-2012, 02:14 PM
#2
Andy is offline Andy
panasonikon
Andy's Avatar
Hi, what uploader are you using?
__________________
Andy
Moon River PhotographyWorkshopsGoogle+FacebookTwitter
Old Apr-28-2012, 12:40 PM
#3
sujit1779 is offline sujit1779 OP
Big grins
Quote:
Originally Posted by Andy View Post
Hi, what uploader are you using?
Hi , I am not using any uploader. I am using REST

Is there any image size limitation for API upload (free or Pro users).

Thanks.
Old Apr-30-2012, 11:12 AM
#4
sujit1779 is offline sujit1779 OP
Big grins
underlying Connection Was Closed: The Connection Was Closed Unexpectedly
Hi,

When I try to upload a big image using C# and API, I get this error

underlying Connection Was Closed: The Connection Was Closed Unexpectedly

My code works perfectly if small size image is uploaded. Can someone point me what to do?

below is my code

==============
Below is my code, can anyone help me out?

=================================
HttpWebResponse response = null;
HttpWebRequest request = null;
Stream str = null;
bool error = false;
StreamReader sr = null;

OAuth.OAuthBase myOAuth = new OAuth.OAuthBase();
string normalizedUrl;
string normalizedRequestParameters;
Uri uri = new Uri("http://upload.smugmug.com/" + Path.GetFileName(path));

string timeStamp = myOAuth.GenerateTimeStamp();
string nonce = myOAuth.GenerateNonce();
myOAuth.includeVersion = true;

string signature = myOAuth.GenerateSignature(uri, Smugmug_CONSUMER_KEY, Smugmug_CONSUMER_SECRET, SmugmugAuthToken
, SmugmugAuthSecret, "PUT", timeStamp, nonce, OAuth.OAuthBase.SignatureTypes.HMACSHA1,
out normalizedUrl, out normalizedRequestParameters);



// string path = @"K:\pics and video\New folder\DSC02235.JPG";
byte[] image = System.IO.File.ReadAllBytes(path);

string hash = calculateMD5Hash(image);
int size = image.Length;

request = (HttpWebRequest)WebRequest.Create("http://upload.smugmug.com/" + Path.GetFileName(path));
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Ssl3;
request.Method = "PUT";
request.ContentLength = size;
request.Timeout = 2147483647;
request.ReadWriteTimeout = 2147483647;
request.ContentType = ContentType(Path.GetExtension(path));

request.Headers["Content-MD5"] = hash;
request.Headers.Add("Authorization", "OAuth oauth_consumer_key=\"" + Smugmug_CONSUMER_KEY + "\",oauth_token=\"" + SmugmugAuthToken
+ "\",oauth_signature_method=\"HMAC-SHA1\",oauth_signature=\"" + HttpUtility.UrlEncode(signature) + "\",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));

request.Headers.Add("Content-Length", size.ToString());

str = request.GetRequestStream();
str.Write(image, 0, size);
str.Flush();
str.Close();

response = (HttpWebResponse)request.GetResponse();
sr = new StreamReader(response.GetResponseStream());

}
=================================

Can someone help me out, I am in urgent need of solution.
Thanks.
Old Apr-30-2012, 04:37 PM
#5
devbobo is offline devbobo
technicolored
devbobo's Avatar
Hi,

What's your SmugMug nickname so that I can do some digging ?

Thanks,

David
__________________
David Parry
SmugMug API Developer
My Photos
Old Oct-12-2012, 05:33 AM
#6
sujit1779 is offline sujit1779 OP
Big grins
Quote:
Originally Posted by devbobo View Post
Hi,

What's your SmugMug nickname so that I can do some digging ?

Thanks,

David
I am uploading using id "picbackman1995@gmail.com", can you tell me why isn't it getting uploaded.

Thanks
Old Oct-14-2012, 01:33 AM
#7
rainforest1155 is offline rainforest1155
with a Heroes touch
rainforest1155's Avatar
Quote:
Originally Posted by sujit1779 View Post
I am uploading using id "picbackman1995@gmail.com", can you tell me why isn't it getting uploaded.

Thanks
Did you take a look at your upload log (account settings > stats > uploads > details)? There select "month" and you'll see a number of different errors.

The "incomplete file" error tells you that the file in question wasn't received completely. During the upload, the connection was likely somehow interrupted. If you're on wireless, try a hard-wired cable connection to your router instead.
It could also be your antivirus, firewall or internet security software interfering.

As for the "invalid file type" errors, that tells you that we didn't recognize the file. The photos might be in a color space that we don't support or perhaps they contain some metadata that we don't support or are corrupted in some way. You can try resaving such photos (using sRGB color profile) in a photo editing program which usually helps. If not, email the HelpDesk with a sample file gets rejected with the "invalid file type" error for us to look at.
__________________
Sebastian
SmugMug Support Hero

look on the bright side
http://www.SebastianHosche.com
Tell The World!  
Similar Threads Thread Starter Forum Replies Last Post
Un-official Unsolicited Vista and Windows 7 Advice Thread Pupator Digital Darkroom 365 May-15-2012 12:04 PM
smugDAV - let's get this show on the road rteng SmugMug APIs, Hacks & Tricks 20 Feb-04-2008 03:11 PM
File Upload - Original File MD5Sum Changes mjohnsonperl SmugMug APIs, Hacks & Tricks 9 Oct-24-2007 01:38 PM


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