Method: GoogleDrive::Session#files

Defined in:
lib/google_drive/session.rb

#files(params = {}, &block) ⇒ Object

Returns list of files for the user as array of GoogleDrive::File or its subclass. You can specify parameters documented at developers.google.com/drive/v3/web/search-parameters

e.g.

session.files
session.files(q: "name = 'hoge'")
session.files(q: ["name = ?", "hoge"])  # Same as above with a placeholder

By default, it returns the first 100 files. You can get all files by calling with a block:

session.files do |file|
  p file
end

Or passing “pageToken” parameter:

page_token = nil
begin
  (files, page_token) = session.files(page_token: page_token)
  p files
end while page_token


185
186
187
188
189
190
191
192
193
# File 'lib/google_drive/session.rb', line 185

def files(params = {}, &block)
  params = convert_params(params)
  execute_paged!(
    method: self.drive.method(:list_files),
    parameters: {fields: '*'}.merge(params),
    items_method_name: :files,
    converter: proc { |af| wrap_api_file(af) },
    &block)
end