Hey everyone! I’m working on an iOS app and I’m trying to figure out how to get a list of files from a specific public folder on Google Drive. Is there a way to do this with the Google Drive iOS SDK?
I’ve been looking into it, but I’m not sure if I need to sign in as a specific user or if I can just access the public folder directly. Here’s what I’m hoping to do:
- Access a public Google Drive folder
- Get a list of all the documents in that folder
- Display the list in my iOS app
Has anyone done something like this before? If so, could you share some tips or point me in the right direction? I’d really appreciate any help or advice you can give me!
Thanks in advance!
hey isaac, i’ve done smth similar before. u can use the GTLRDriveQuery_FilesList class to get files from a public folder. u don’t need to sign in for public stuff. just set the ‘q’ parameter to search for files in the specific folder. hope this helps!
I’ve tackled this issue in one of my projects. The Google Drive iOS SDK is quite powerful for this task. Here’s what worked for me:
First, you’ll need to set up the GTLRDriveService. Then, use GTLRDriveQuery_FilesList to query the public folder. Set the ‘q’ parameter to something like “‘[folder_id]’ in parents and trashed = false”. This fetches all non-trashed files in the specified folder.
One gotcha: make sure you have the correct scope in your GIDSignIn configuration, even for public folders. I used “https://www.googleapis.com/auth/drive.readonly”.
After executing the query, you’ll get a GTLRDrive_FileList object. Iterate through its ‘files’ property to access individual GTLRDrive_File objects, which contain metadata like name, ID, and mimeType.
Remember to handle pagination if there are many files. The SDK supports this with the ‘pageToken’ parameter.
Hope this helps you get started!
Based on my experience with the Google Drive iOS SDK, it is possible to access public folders without requiring user authentication. The process involves creating a query using GTLRDriveQuery_FilesList and setting the query’s parameter to filter files by the folder ID. In practice, this means ensuring you only retrieve non-trashed items and managing large collections through pagination with the nextPageToken. It is essential to implement proper error handling to manage any issues during API calls, which has proven effective in my recent project work.