所有的代碼運行沒有錯誤,但當我檢查我的谷歌雲端硬盤帳戶我找不到我上傳的文件(「document.txt」)。無法上傳文件到谷歌驅動器 - 使用c#
此外它又要求我再次進行身份驗證。
UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
new ClientSecrets
{
ClientId = "Here my clientid",
ClientSecret = "client secret",
},
new[] { DriveService.Scope.Drive },
"user",
CancellationToken.None).Result;
// Create the service.
var service = new DriveService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Drive API Sample",
});
File body = new File();
body.Title = "My document";
body.Description = "A test document";
body.MimeType = "text/plain";
byte[] byteArray = System.IO.File.ReadAllBytes("document.txt");
System.IO.MemoryStream stream = new System.IO.MemoryStream(byteArray);
FilesResource.InsertMediaUpload request = service.Files.Insert(body, stream, "text/plain");
request.Upload();
File file = request.ResponseBody;
問題: 爲什麼不能找到我上傳的文件,我怎麼能得到它記住我的身份驗證。
感謝您的回覆。 我會做建議的變化 – 2014-12-03 11:51:36
你可以找到示例項目沿着這裏https://github.com/LindaLawton/Google-Dotnet-Samples/tree/master/Google-Drive – DaImTo 2014-12-03 11:57:03
偉大的教程。讓我檢查一下。 – 2014-12-03 11:59:43