大家好,我在我的应用程序中使用了 google-api-client gem 我想获取文件夹中所有图像的列表我该如何实现。这是我的代码,仅在第一页上获取所有文件的列表。
require 'google/apis/drive_v2'
require 'signet/oauth_2/client'
require 'googleauth'
Drive = Google::Apis::DriveV2 # Alias the module
drive = Drive::DriveService.new
drive.authorization = authorization
files = drive.list_files
请告诉我如何获取文件夹内所有文件的列表。就像我有一个名为“test_folder”的文件夹,我在该文件夹中有一些文件,现在我想获取所有文件的列表。 请帮我。
最佳答案
您需要使用参数 q
和值 '#{folder_id}' an parents
如果文件夹位于共享驱动器中,则需要将 supports_all_drives
和 include_items_from_all_drives
设置为 true
。
下面是我的代码,用于在共享驱动器的指定文件夹中查找具有指定名称的文件。
query = "name = '#{file_name}' and '#{FOLDER_ID}' in parents"
response = drive_service.list_files(
q: query,
fields: "files(id, name)",
supports_all_drives: true,
include_items_from_all_drives: true
)
关于ruby-on-rails - 如何使用 ruby 中的 Google Drive api 获取 Google Drive 文件夹中所有文件的列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40176621/