Thursday 15 April 2010

How to check if a folder exists in google drive? (ruby client) -


It seems that I can only return the contents of a folder, but there is no information about the folder.

  Result = client.execute ({: api_method => drive.files.list,: q = & gt; "mimeType = 'app / vnd.google-apps.folder' and Trashed = false and title = '# {App_folder_name}' ",: maxResults => 1})   

returned results. To_hash ["Item"] is populated with the contents of the array folder (sub folders and files). How do I get information about folders only? What I want to do, checks whether it exists or not. And it seems that more than one entry is being neglected in the array.

A folder Google Drive is like a regular file but a special MIME type ("app / vnd. Google-apps.folder "). After you have the ID of the folder, you can access the metadata with a request:

  ## # Print the file's metadata # # the ultimate [Google :: epicilient] Client #Official Client Instance # @ PRAM [String] File_ID # To print the #RetinNil DRP print_file (client, file_id) drive = client. Diskped_pi ('drive', 'V2') result = client.execute (: api_method = & gt; @ drive.files.get ,: parameter = & gt; {'fileId' = & gt; file_id}) if result.status == 200 file = result.data "title: # {file.title}" puts "Description: # {file.description}" puts "MIME type: # {file.mime_type}" and adds "An error occurred: # {Result.data ['error'] ['message']} "end and end    

No comments:

Post a Comment