本文介绍了从Google云端硬盘或一个驱动器中检索特定文件夹中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我想加载我的图像滑块,哪个图像来自谷歌驱动器或一个驱动器。我使用下面的代码进行谷歌驱动,但它返回所有文件,我想从特定文件夹中获取。 GoogleConnect.ClientId = xxxxxx; GoogleConnect.ClientSecret = xxxxxx; GoogleConnect.RedirectUri = Request.Url.AbsoluteUri.Split(' ?')[ 0 ]; GoogleConnect.API = EnumAPI.Drive; if (!string.IsNullOrEmpty(Request.QueryString [ code])) { string code = Request.QueryString [ code]; string json = GoogleConnect.Fetch( 我,代码); GoogleDriveFiles files = new JavaScriptSerializer()。反序列化< GoogleDriveFiles>(json); // 这将返回文件 } else if (Request.QueryString [ error] == access_denied) { ClientScript.RegisterClientScriptBlock( this .GetType(), alert, alert('Access denied。'), true ); } 解决方案 优秀教程: http://www.daimto.com/google-drive-api-c/ [ ^ ] 试试这个 Private Sub GetFileList(ParentFolder As String ) 授权()' 照顾授权......你可以用JS来询问用户和获取Auth令牌 ' MSO - 20130423 - 使用指定的foldername ' 创建搜索请求 Dim oListReq As Google.Apis.Drive.v2.FilesResource.ListRequest Dim oFileList As FileList ' mimeType = ' application / vnd.google-apps.folder' oListReq = oDriveService .Files.List() ' 搜索特定文件名 oListReq.Q = mimeType =' application / vnd.google-apps.folder ' and title =' + ParentFolder + ' 和trashed = false oListReq.Fields =items / id' MSO - 20130621 - 仅限ID 下一个查询 oListReq.MaxResults = 10 ' 最多10个文件(也可能只有1个) '获取结果 oFileList = oListReq .Fetch() ' 预计只有1个结果如果oFileList.Items.Count = 1那么 Dim oFile As File = oFileList.Items(0) FolderId = oFile.Id'获取FolderId 结束如果 oListReq = oDriveService.Files.List() ' 在 oListReq.Q =' + FolderId + ' 和trashed = false' oListReq.Fields = items(id,alternateLink) ' MSO - 20130621 - 如果只需要某些字段,请优化查询 '获取结果 oFileList = oListReq.Fetch() ' TODO:oFileList现在有文件夹中的文件列表,但可能有更多页面 End Sub I want to load my slider of image which image comes from google drive or one drive. i used below code for google drive but it returns all the files and i want to get from specific folder.GoogleConnect.ClientId = "xxxxxx";GoogleConnect.ClientSecret = "xxxxxx";GoogleConnect.RedirectUri = Request.Url.AbsoluteUri.Split('?')[0];GoogleConnect.API = EnumAPI.Drive;if (!string.IsNullOrEmpty(Request.QueryString["code"])){ string code = Request.QueryString["code"]; string json = GoogleConnect.Fetch("me", code); GoogleDriveFiles files = new JavaScriptSerializer().Deserialize<GoogleDriveFiles>(json); // This will returns the files }else if (Request.QueryString["error"] == "access_denied"){ ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('Access denied.')", true);} 解决方案 excellent tutorial here:http://www.daimto.com/google-drive-api-c/[^]try thisPrivate Sub GetFileList(ParentFolder As String) Authorize() 'Take care of authorization... you could use JS to ask the user and get the Auth Token 'MSO - 20130423 - Search the Google Drive File with the specified foldername 'Create the search request Dim oListReq As Google.Apis.Drive.v2.FilesResource.ListRequest Dim oFileList As FileList 'mimeType = 'application/vnd.google-apps.folder' oListReq = oDriveService.Files.List() 'Search for a specific file name oListReq.Q = "mimeType = 'application/vnd.google-apps.folder' and title = '" + ParentFolder + "' and trashed=false" oListReq.Fields = "items/id" 'MSO - 20130621 - only ID needed for next query oListReq.MaxResults = 10 'Max 10 files (too may I Expect only 1) 'Get the results oFileList = oListReq.Fetch() 'Only 1 result is expected If oFileList.Items.Count = 1 Then Dim oFile As File = oFileList.Items(0) FolderId = oFile.Id 'Get FolderId End If oListReq = oDriveService.Files.List() 'Search for a specific file name in the folder oListReq.Q = "'" + FolderId + "' in parents and trashed=false " 'oListReq.Fields = "items(id,alternateLink)" 'MSO - 20130621 - Optimize your query if you need only certain fields 'Get the results oFileList = oListReq.Fetch() 'TODO: oFileList now have the list of the files in the folder, but there could me more "pages"End Sub 这篇关于从Google云端硬盘或一个驱动器中检索特定文件夹中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-15 10:25