A
A
AigizK2011-08-22 16:15:08
Google
AigizK, 2011-08-22 16:15:08

Loading RAR and ZIP archives via Google Documents List Data API v3.0 using .NET

Does anyone know if it's possible to upload archives via the API? An error occurs when using the code from the code.google.com/p/google-gdata/source/browse/trunk/clients/cs/samples/DocListUploader/HiddenForm.cs example . Although, on the other hand, you can download archives using a browser.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AigizK, 2011-08-23
@AigizK

The answer is yes you can. You just need to upload via ResumableUploader. Here is an example:

var service = new GoogleDocument("email", "password");
ClientLoginAuthenticator cla = new ClientLoginAuthenticator("111", 
            ServiceNames.Documents,service.Credentials);
ResumableUploader ru = new ResumableUploader();

// Set metadata for our upload.
Document entry = new Document();
entry.Title = "My Archive.zip";
entry.MediaSource = new MediaFileSource("c:\\111.zip", "application/octet-stream");

 // Add the upload uri to document entry.
 Uri createUploadUrl = 
              new Uri("https://docs.google.com/feeds/upload/create-session/default/private/full");
AtomLink link = new AtomLink(createUploadUrl.AbsoluteUri);
link.Rel = ResumableUploader.CreateMediaRelation;
entry.DocumentEntry.Links.Add(link);

ru.Insert(cla, entry.DocumentEntry);

The only thing that's confusing is the MediaFileSource. But I haven't found another way yet, but this one works.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question