0
有沒有辦法讓我通過Drive API檢索校驗和?谷歌驅動器校驗和
This answer通過文檔「試試」功能,它有一個可怕的界面。
如何通過.NET(C#)Google Drive API執行此操作? 或者,我如何使用我自己的帖子/獲取請求來做到這一點?
有沒有辦法讓我通過Drive API檢索校驗和?谷歌驅動器校驗和
This answer通過文檔「試試」功能,它有一個可怕的界面。
如何通過.NET(C#)Google Drive API執行此操作? 或者,我如何使用我自己的帖子/獲取請求來做到這一點?
嘗試.NET Quickstart,因爲它的基本列表文件方法。
using Google.Apis.Auth.OAuth2;
using Google.Apis.Drive.v3;
using Google.Apis.Drive.v3.Data;
using Google.Apis.Services;
using Google.Apis.Util.Store;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace DriveQuickstart
{
class Program
{
// If modifying these scopes, delete your previously saved credentials
// at ~/.credentials/drive-dotnet-quickstart.json
static string[] Scopes = { DriveService.Scope.DriveReadonly };
static string ApplicationName = "Drive API .NET Quickstart";
static void Main(string[] args)
{
UserCredential credential;
using (var stream =
new FileStream("client_secret.json", FileMode.Open, FileAccess.Read))
{
string credPath = System.Environment.GetFolderPath(
System.Environment.SpecialFolder.Personal);
credPath = Path.Combine(credPath, ".credentials/drive-dotnet-quickstart.json");
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
Scopes,
"user",
CancellationToken.None,
new FileDataStore(credPath, true)).Result;
Console.WriteLine("Credential file saved to: " + credPath);
}
// Create Drive API service.
var service = new DriveService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = ApplicationName,
});
// Define parameters of request.
FilesResource.ListRequest listRequest = service.Files.List();
listRequest.PageSize = 10;
listRequest.Fields = "nextPageToken, files(id, name)";
// List files.
IList<Google.Apis.Drive.v3.Data.File> files = listRequest.Execute()
.Files;
Console.WriteLine("Files:");
if (files != null && files.Count > 0)
{
foreach (var file in files)
{
Console.WriteLine("{0} ({1})", file.Name, file.Id);
}
}
else
{
Console.WriteLine("No files found.");
}
Console.Read();
}
}
}
}
}
編輯這一行:
listRequest.Fields = "nextPageToken, files(id, name)";
要:
listRequest.Fields = "nextPageToken, files(id, name, md5Checksum)";
從上面的鏈接的解決方案是正確的,試試吧功能將幫助您熟悉每一種方法以及如何響應和請求形成。
希望這會有所幫助。
謝謝,我結束瞭如何去做。 – Tobiq