DocumentListEntry currentEntry = docs.service.getEntry(
new URL(DEFAULT_DOCLIST_FEED_URL + "/" + docIdToUpdate),
DocumentListEntry.class);
MediaFileSource mediaFile = getMediaFileSource(filePath);
ResumableGDataFileUploader uploader =
new ResumableGDataFileUploader
.Builder(docs.service, mediaFile, currentEntry)
.title(mediaFile.getName())
.requestType(
ResumableGDataFileUploader.RequestType.UPDATE_MEDIA_ONLY)
.build();
uploader.start();
// wait for upload to complete
while (!uploader.isDone()) {
try {
Thread.sleep(100);
} catch (InterruptedException ie) {
output.println("Media update interrupted at: "
+ String.format("%3.0f", uploader.getProgress() * 100) + "%");
throw ie; // rethrow
}
}
DocumentListEntry updatedEntry =
uploader.getResponse(DocumentListEntry.class);
output.println("Finished update");
}