Google drive api 如何检查google drive中是否存在文件夹?(ruby客户端)

Google drive api 如何检查google drive中是否存在文件夹?(ruby客户端),google-drive-api,Google Drive Api,似乎我只能返回文件夹的内容,但无法返回有关文件夹本身的信息 results = client.execute({ :api_method => drive.files.list, :q => "mimeType='application/vnd.google-apps.folder' AND trashed=false AND title='#{app_folder_name}'", :maxResults => 1 }) 返回的结果。to_h

似乎我只能返回文件夹的内容,但无法返回有关文件夹本身的信息

  results = client.execute({
    :api_method => drive.files.list,
    :q => "mimeType='application/vnd.google-apps.folder' AND trashed=false AND title='#{app_folder_name}'",
    :maxResults => 1
  })

返回的结果。to_hash[“items”]数组由文件夹(包括子文件夹和文件)的内容填充。如何获取有关文件夹本身的信息?我只想检查它是否存在。而且似乎maxResults也被忽略了,因为数组有多个条目。

Google Drive上的文件夹类似于普通文件,但有一个特殊的MIME类型(“application/vnd.Google apps.folder”)。获得文件夹id后,可以通过请求访问其元数据:


如果我不知道身份怎么办。。。至少在我的测试环境中,我希望仅根据文件夹的名称和父文件夹检查该文件夹是否存在。文件和文件夹名称不唯一,因此这可能不是最安全的方法。无论如何,代码应该返回文件夹的元数据,而不是文件夹内容。您能在OAuth 2.0游乐场()上尝试相同的请求吗?
##
# Print a file's metadata.
#
# @param [Google::APIClient] client
#   Authorized client instance
# @param [String] file_id
#   ID of file to print
# @return nil
def print_file(client, file_id)
  drive = client.discovered_api('drive', 'v2')
  result = client.execute(
    :api_method => @drive.files.get,
    :parameters => { 'fileId' => file_id })
  if result.status == 200
    file = result.data
    puts "Title: #{file.title}"
    puts "Description: #{file.description}"
    puts "MIME type: #{file.mime_type}"
  else
    puts "An error occurred: #{result.data['error']['message']}"
  end
end