Closed GoogleCodeExporter closed 8 years ago
Forgot to add error message...
System.Net.WebException: The remote server returned an error: (411) Length
Required.
at System.Net.HttpWebRequest.GetResponse()
at Google.GData.Client.ResumableUpload.ResumableUploader.InitiateUpload(Uri resumableUploadUri, Authenticator authentication, String contentType, String slug, Int64 contentLength, String httpMethod) in C:\YT SDK\clients\cs\src\core\resumableupload.cs:line 619
at Google.GData.Client.ResumableUpload.ResumableUploader.InitiateUpload(Uri resumableUploadUri, Authenticator authentication, String contentType, String slug, Int64 contentLength) in C:\YT SDK\clients\cs\src\core\resumableupload.cs:line 600
at Google.GData.Client.ResumableUpload.ResumableUploader.Insert(Authenticator authentication, Uri resumableUploadUri, Stream payload, String contentType, String slug, AsyncData data) in C:\YT SDK\clients\cs\src\core\resumableupload.cs:line 202
at Google.GData.Client.ResumableUpload.ResumableUploader.AsyncInsertWorker(AsyncResumableUploadData data, AsyncOperation asyncOp, SendOrPostCallback completionMethodDelegate) in C:\YT SDK\clients\cs\src\core\resumableupload.cs:line 274 -
Original comment by earwax...@gmail.com
on 20 Apr 2012 at 5:11
I have hacked a away around this by forcing the content length to 0 as follows
(starting line 603 of resumableupload.cs). The issue is now solved for me and I
can upload.
/// <summary>
/// retrieves the resumable URI for the rest of the operation. This will initiate the
/// communication with resumable upload server by posting against the starting URI
/// </summary>
/// <param name="resumableUploadUri"></param>
/// <param name="authentication"></param>
/// <param name="entry"></param>
/// <returns>The uri to be used for the rest of the operation</returns>
public Uri InitiateUpload(Uri resumableUploadUri, Authenticator authentication, string contentType, string slug, long contentLength, string httpMethod) {
HttpWebRequest request = PrepareRequest(resumableUploadUri,
authentication,
slug,
contentType,
contentLength,
httpMethod);
// Zero the content length
request.ContentLength = 0;
WebResponse response = request.GetResponse();
return new Uri(response.Headers["Location"]);
}
Original comment by earwax...@gmail.com
on 20 Apr 2012 at 5:57
Thanks for reporting the bug and for the quick fix, I committed your patch in
rev. 1174:
http://code.google.com/p/google-gdata/source/detail?r=1174
Original comment by ccherub...@google.com
on 20 Apr 2012 at 8:41
I ran into the same issue but with the normal Insert method. I used this
overload:
public TEntry Insert<TEntry>(Uri feedUri, TEntry entry) where TEntry : AtomEntry;
I looked into the problem and have fixed it by adding the following line to
google-gdata\clients\cs\src\core\request.cs (line 525):
web.ContentLength = this.ContentLength;
That function creates a Request object based on the GDataRequest object. When
doing that it copies the properties which both classes have. It seems that the
ContentLength property was just forgotten.
@ccherubino, can you commit this patch?
Original comment by mark%lag...@gtempaccount.com
on 3 May 2012 at 2:19
Attachments:
Thanks for the patch, Mark.
I'm going to test it as soon as possible, but I must be extra careful as the
method you are changing, EnsureWebRequest(), is used by all APIs.
Original comment by ccherub...@google.com
on 3 May 2012 at 10:19
Original issue reported on code.google.com by
earwax...@gmail.com
on 20 Apr 2012 at 5:03