Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 4.0 使用带有服务帐户的Google Drive V3 APi,有没有办法在浏览器中打开web视图链接_C# 4.0_Asp.net Web Api_Iis 7_Google Drive Api_Windows Server 2008 R2 - Fatal编程技术网

C# 4.0 使用带有服务帐户的Google Drive V3 APi,有没有办法在浏览器中打开web视图链接

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

我在IIS上托管我的网站,并使用服务帐户上载和请求驱动器文件。我可以获取webViewLink,但由于它是一个服务帐户,因此它不会显示此链接上的文件,但会出现权限问题,即服务帐户应授予该权限

在使用代码为特定用户授予权限时,在该用户的驱动器中,我可以看到该文件。但我的问题是如何使用
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完整请求/响应以及预期的内容。