v1.10 Assert in GDataHTTPUploadFetcher:uploadNextChunkWithOffset:

196 views
Skip to first unread message

Christoph Z.

unread,
Apr 1, 2010, 11:22:29 PM4/1/10
to Google Data APIs Objective-C Client Library Discussion
Hi,

I've changed my project to use uploadLink (as per
http://groups.google.com/group/gdata-objectivec-client/browse_thread/thread/3d88be37d31c457a
). However, now I get an assert in:

GDataHTTPUploadFetcher.m uploadNextChunkWithOffset:fetcherProperties:
(line 318)

#if DEBUG
NSAssert2(offset < dataLen, @"offset %lu exceeds data length %lu",
offset, dataLen);
#endif

This happens when I try to insert a 0-length doc entry (with just the
title) :

POST URL:
http://docs.google.com/feeds/upload/create-session/default/private/full/folder%3A0B2KcmAEFPLoOOTJjOWExNzEtYzc0Yi00Y2Q1LTg2M2MtYTRjMWE3MWFhNjE2/contents

{
Accept = "application/atom+xml, text/xml";
Authorization = "GoogleLogin auth=...";
"Cache-Control" = "no-cache";
"Content-Length" = 399;
"Content-Type" = "application/atom+xml; charset=utf-8";
"Gdata-Version" = "3.0";
Slug = Bar;
"User-Agent" = "...";
"X-Upload-Content-Length" = 0;
"X-Upload-Content-Type" = "text/plain";
}

How can I upload an empty document? The postLink doesn't seem to work
either (I get the assert from the previous post).

Any ideas?

Thanks,
Christoph

Greg Robbins

unread,
Apr 1, 2010, 11:55:02 PM4/1/10
to gdata-objec...@googlegroups.com
Since the new upload protocol involves multiple http fetches to transfer files in chunks, you shouldn't upload an empty file, as that would waste http transactions. 

Rather, just insert the entry without a file, like this:

NSURL *uploadURL;
if ([fileData length] > 0) {
  // upload file data with the document entry
  [newEntry setUploadData:fileData];
  [newEntry setUploadMIMEType:mimeType];
  [newEntry setUploadSlug:[path lastPathComponent]];
  uploadURL = [GDataServiceGoogleDocs docsUploadURL];
} else {
  // upload only the document entry
  uploadURL = [[mDocListFeed postLink] URL];
}

ticket = [service fetchEntryByInsertingEntry:newEntry forFeedURL:uploadURL ...]

Christoph Z.

unread,
Apr 2, 2010, 12:12:54 AM4/2/10
to Google Data APIs Objective-C Client Library Discussion
The problem is that when I use the postLink in this case, I get the
"unexpected response data" in GDataHTTPUploadFetcher.m:241.

I also tried to setting serviceUploadChunkSize to 0, but then I get a
strange "upload data must be paired with MIME type", despite the fact
that the MIME type is set correctly.

Greg Robbins

unread,
Apr 2, 2010, 1:37:46 AM4/2/10
to gdata-objec...@googlegroups.com
"unexpected response data" and "upload data must be paired with MIME type " occur because a file or data pointer, even for an empty file or a 0-length NSData, was set for uploading on the entry. 

If the file or data is empty, do not call any of the -setUpload...: methods on the entry; those should remain nil.

Christoph Z.

unread,
Apr 2, 2010, 3:37:41 AM4/2/10
to Google Data APIs Objective-C Client Library Discussion
This does take care of the 0-length document uploads. I just hit an
issue with updates:

I use the uploadEditLink as per your earlier post. The updates seem to
succeed (we get status 200), but the document does not get updated.
Here's the code:

if (uploadData.length > 0)
{
[remoteEntry setUploadData:uploadData];
[remoteEntry setUploadMIMEType:@"text/plain"];
[remoteEntry setUploadSlug:title];

editURL = [[remoteEntry uploadEditLink] URL];
}
else
{
editURL = [[remoteEntry editLink] URL];
}

self.ticket = [self.service fetchEntryByUpdatingEntry:remoteEntry
forEntryURL:editURL delegate:self

didFinishSelector:@selector(remoteUpdateTicket:finishedWithEntry:error:)];

didFinishSelector gets called with nil error, as expected. The
document contains old data though. I've waited few minutes to double
check - but no. When I disable chunked uploads (by settings
serviceUploadChunkSize to 0) and use editMediaLink instead, updates
work correctly.

Is this a bug or am I missing something?

Greg Robbins

unread,
Apr 2, 2010, 4:17:02 AM4/2/10
to gdata-objec...@googlegroups.com
From a few quick tests and looking at the http log from the library, I think you're seeing a server bug. I'll follow up with the Docs API server team.

Greg Robbins

unread,
Apr 2, 2010, 5:43:36 PM4/2/10
to gdata-objec...@googlegroups.com
We're tracking the problem updating entries via chunked uploads as bugstar 2567802.

Brady White

unread,
Apr 12, 2010, 1:08:27 AM4/12/10
to Google Data APIs Objective-C Client Library Discussion
I'm seeing this same result. I'm updating a document with no error
being returned, yet the document is never updated on the server. Has
this been fixed? Should I just use the editMediaLink workaround?

Greg Robbins

unread,
Apr 12, 2010, 1:34:48 AM4/12/10
to gdata-objec...@googlegroups.com
I believe the workaround is still necessary.
Reply all
Reply to author
Forward
0 new messages