How to upload/update file by FileStream and ResumableUploader in C#

折月煮酒 提交于 2019-12-02 10:57:05

Try the following code:

DocumentsService service = new DocumentsService("MyDocumentsListIntegration-v1");
ClientLoginAuthenticator authenticator = new ClientLoginAuthenticator(APPLICATION_NAME, ServiceNames.Documents, USERNAME, PASSWORD);

string slug = "Legal contract";
MediaFileSource mediaSource = new MediaFileSource("c:\\contract.txt", "text/plain");
Uri createUploadUrl = new Uri("https://docs.google.com/feeds/upload/create-session/default/private/full?v=3");

ResumableUploader ru = new ResumableUploader();
ru.InsertAsync(authenticator, createUploadUrl, mediaSource.GetDataStream(), mediaSource.ContentType, slug, new object());
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!