• 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

Need some help with your New SmugMug Site?

Dgrin Challenges

Our Challenges moderator has lined up an new set of challenges for you. The Weekly Word Challenge. Get all the details and participate in the conversation Weekly Word Challenge.

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

Looking for a little challenge? The Dgrin Mini-Challenges are a great way to challenge yourself. Take a moment to look through past winners and find the current Mini Challenge here.

From Around the Net

Enjoy a few of our favorite articles from around the 'net. If you have something you think we should see, post it here and we'll have a look.

Journeys

Landscapes

Sports

 
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
Bicameral
Andy's Avatar
Hi, what uploader are you using?
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 online now devbobo
LR whisperer
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
SmugMug Support Hero
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