C# 4.0 使用带有服务帐户的Google Drive V3 APi,有没有办法在浏览器中打开web视图链接
我在IIS上托管我的网站,并使用服务帐户上载和请求驱动器文件。我可以获取webViewLink,但由于它是一个服务帐户,因此它不会显示此链接上的文件,但会出现权限问题,即服务帐户应授予该权限 在使用代码为特定用户授予权限时,在该用户的驱动器中,我可以看到该文件。但我的问题是如何使用C# 4.0 使用带有服务帐户的Google Drive V3 APi,有没有办法在浏览器中打开web视图链接,c#-4.0,asp.net-web-api,iis-7,google-drive-api,windows-server-2008-r2,C# 4.0,Asp.net Web Api,Iis 7,Google Drive Api,Windows Server 2008 R2,我在IIS上托管我的网站,并使用服务帐户上载和请求驱动器文件。我可以获取webViewLink,但由于它是一个服务帐户,因此它不会显示此链接上的文件,但会出现权限问题,即服务帐户应授予该权限 在使用代码为特定用户授予权限时,在该用户的驱动器中,我可以看到该文件。但我的问题是如何使用System.Diagnostics.Process.Start(newFile.webViewLink) 以下是我上传和获取文件的代码: { File fileInGoogleDrive = Utils.uplo
System.Diagnostics.Process.Start(newFile.webViewLink)
以下是我上传和获取文件的代码:
{ File fileInGoogleDrive = Utils.uploadToDrive(service, pathOfTheFileToBeUploaded, "root");
File metadata = Utils.GetFileRequestedMetadata(service, fileInGoogleDrive.Id);
Permission toShare = new Permission();
toShare.EmailAddress = "xyz@gmail.com";
toShare.Type = "user";
toShare.Role = "reader";
PermissionsResource.CreateRequest createRequest = service.Permissions.Create(toShare, metadata.Id);
createRequest.Execute();
return metadata.WebViewLink;
}
public static File uploadToDrive(DriveService _service, string _uploadFile, string _parent = "root")
{
if (!String.IsNullOrEmpty(_uploadFile))
{
//string mimeType = GetMimeType(_uploadFile); // We can have mime type passed in request
File fileMetadata = new File();
fileMetadata.Name = System.IO.Path.GetFileName(_uploadFile);
fileMetadata.MimeType = GetMimeType(_uploadFile);
byte[] byteArray = System.IO.File.ReadAllBytes(_uploadFile);
System.IO.MemoryStream stream = new System.IO.MemoryStream(byteArray);
FilesResource.CreateMediaUpload request = _service.Files.Create(fileMetadata, stream, GetMimeType(_uploadFile));
request.Upload();
return request.ResponseBody;
}
我仍然被这个问题难住了。有人能给我一些提示吗?看起来像是复制品。如果这是不同的,您可以提供HTTP完整请求/响应以及预期的内容。