这是该链接中原始问题的延续。
通过以下代码,我可以获取1000条记录,但是驱动器中总共有6500 ++条记录。正在搜寻google,但找不到正确的解决方案。
作为参考,参数“ pageSize”的描述值为“每页最多可返回的文件数。可接受的值为1到1000,包括端点。(默认值:100)”。
因此,这意味着我们只能获得1000条记录,或者如果可能的话,那是怎么回事。另外,我不了解参数“ pageToken”,“ nextPageToken”值的实时用法是什么。
代码:(https://developers.google.com/drive/v3/web/quickstart/dotnet)
namespace gDrive
{
class Program
{
static string[] Scopes = { DriveService.Scope.DriveReadonly };
static string ApplicationName = "Drive API .NET Quickstart";
static void Main(string[] args)
{
UserCredential credential;
gDriveTableAdapter gDrive = new gDriveTableAdapter();
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: " + …Run Code Online (Sandbox Code Playgroud) 我可以通过以下引用使用API从Google Drive获取文件:在ASP.Net中使用C#和VB.Net在Google Drive中使用Google Drive API显示(查看)文件列表。
但是我只得到100条记录。我有成千上万的记录。任何人都可以让我知道要更改以获取完整记录显示的内容。
请在下面找到代码:
namespace GoogleDrive
{
public partial class gDrive : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
GoogleConnect.ClientId = "942196220502-k107l4mtn6n606d8m38pp2k6clfmbftd.apps.googleusercontent.com";
GoogleConnect.ClientSecret = "oJxTZ2Bw9QfOlrc7KgxsEf9o";
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);
gv1.DataSource = files.Items.Where(i => i.Labels.Trashed == false);
gv1.DataBind();
}
else if (Request.QueryString["error"] == "access_denied")
{
ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('Access denied.')", true);
}
else
{
GoogleConnect.Authorize("https://www.googleapis.com/auth/drive.readonly");
} …Run Code Online (Sandbox Code Playgroud)