In this article, we will create a new Google project, add a service account to the project, generate a service account ID and a private key, enable Google Drive API and finally validate the domain on which your server is running. I hope these small examples can serve as a base to figure out how to make more operations with the Google Drive API, the complete code can be found here.Creating Google Service Account and Enabling Google API list(q=f"mimeType='application/' and name = 'įile_metadata = įile = service.files().copy(fileId=file_id, The “q” parameter supports combining different criteria, for example, to search by mimeType and name: results = service.files() PageSize=10, fields="nextPageToken, files(id, name)").execute() To search files we make use of the list function, there is a parameter called “q” for filtering and searching, to search a file by name: results = service.files() Now let’s see some of the operations: Searching files Once we have built a service object, we can make calls to the Files resource by calling functions on service.files().ĭepending on the operation we want to perform, we will need to use the appropriate scope, for example, to download a file it will be enough to use, but for these code snippets, I will be using to have full access, available scopes can be found here. ![]() Most of the operations shown in this post are using the methods from the Files resource. This is a follow-up to a previous post on how to connect to Google Drive using a service account with Python, for this post we are going to see how to do some common operations like downloading and uploading files, searching, copying, and deleting.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |