Upload problems...
AdamN
Registered Users Posts: 18 Big grins
Hi. A no brainer question I'm sure, but what am I missing here...
I'm trying to upload an image using the http PUT thingie. However I consistently get "status: fail, Code: 4, Message: wrong format (ByteCount given: 432974, received: 432974. MD5Sum given: c56ce91f757c469960c79ba69f7d96fb, actual: c56ce91f757c469960c79ba69f7d96fb."
And heres the code in C#:
byte[] image = File.ReadAllBytes(path);
string hash = _smugHelper.calculateMD5Hash(image);
int size = image.Length;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://upload.smugmug.com/" + Path.GetFileName(path));
request.Method = "PUT";
request.ContentLength = size;
request.ContentType = "image/jpg";
request.Headers/SIZE][SIZE=2][COLOR=#a31515]"Content-MD5"[/COLOR][/SIZE][SIZE=2 = hash;
request.Headers.Add("X-Smug-SessionID", sessionId);
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));
if (imageId != 0)
request.Headers.Add("X-Smug-ImageID ", imageId.ToString());
Stream str = request.GetRequestStream();
str.Write(image, 0, size);
str.Flush();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader sr = newStreamReader(response.GetResponseStream());
string respString = sr.ReadToEnd();
return 1;
Please help!
I'm trying to upload an image using the http PUT thingie. However I consistently get "status: fail, Code: 4, Message: wrong format (ByteCount given: 432974, received: 432974. MD5Sum given: c56ce91f757c469960c79ba69f7d96fb, actual: c56ce91f757c469960c79ba69f7d96fb."
And heres the code in C#:
byte[] image = File.ReadAllBytes(path);
string hash = _smugHelper.calculateMD5Hash(image);
int size = image.Length;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://upload.smugmug.com/" + Path.GetFileName(path));
request.Method = "PUT";
request.ContentLength = size;
request.ContentType = "image/jpg";
request.Headers/SIZE][SIZE=2][COLOR=#a31515]"Content-MD5"[/COLOR][/SIZE][SIZE=2 = hash;
request.Headers.Add("X-Smug-SessionID", sessionId);
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));
if (imageId != 0)
request.Headers.Add("X-Smug-ImageID ", imageId.ToString());
Stream str = request.GetRequestStream();
str.Write(image, 0, size);
str.Flush();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader sr = newStreamReader(response.GetResponseStream());
string respString = sr.ReadToEnd();
return 1;
Please help!
0
Comments
Ok, turns out that sending the hash in capital letters isn't supported by the API. However it returns my hash in lower letters so figuring out what was wrong was a bit tricky. It almost registers as a bug in my world either you support capitall hashes OR you return the actual error..
/Adam