You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are many methods to create and update file metadata and contents. With *PyDrive2*, all you have to know is
41
41
`Upload()`_ method which makes optimal API call for you. Add the following code to your *quickstart.py* and run it.
@@ -57,8 +57,8 @@ This code will create a new file with title *Hello.txt* and its content *Hello W
57
57
.. _`Google Drive`: https://drive.google.com
58
58
.. _`File management made easy`: ./filemanagement.html
59
59
60
-
Getting list of files
61
-
---------------------
60
+
Listing Files
61
+
-------------
62
62
63
63
*PyDrive2* handles paginations and parses response as list of `GoogleDriveFile`_. Let's get title and id of all the files in the root folder of Google Drive. Again, add the following code to *quickstart.py* and execute it.
64
64
@@ -84,23 +84,26 @@ GoogleDrive treats everything as a file and assigns different mimetypes for diff
84
84
return newFolder
85
85
86
86
87
-
Get Id of the title
88
-
-------------------
87
+
Return File ID via File Title
88
+
-----------------------------
89
89
90
-
``get_id_of_title`` is a function that return id of the given title's file in the directory.
90
+
A common task is providing the Google Drive API with a file id.
91
+
``get_id_of_title`` demonstrates a simple workflow to return the id of a file handle by searching the file titles in a
92
+
given directory. The function takes two arguments, ``title`` and ``parent_directory_id``. ``title`` is a string that
93
+
will be compared against file titles included in a directory identified by the ``parent_directory_id``.
91
94
92
95
.. code-block:: python
93
96
94
97
defget_id_of_title(title,parent_directory_id):
95
98
foldered_list=drive.ListFile({'q': "'"+parent_directory_id+"' in parents and trashed=false"}).GetList()
96
99
forfilein foldered_list:
97
-
if(file['title']==title):
98
-
returnfile['id']
99
-
returnNone
100
+
if(file['title']==title):
101
+
returnfile['id']
102
+
returnNone
100
103
101
-
folder browser
104
+
Browse Folders
102
105
--------------
103
-
This return a json output of the data in the directory with some important attributes like size, title, parent_id etc
106
+
This returns a json output of the data in a directory with some important attributes like size, title, parent_id.
104
107
105
108
.. code-block:: python
106
109
@@ -136,7 +139,7 @@ This return a json output of the data in the directory with some important attri
136
139
137
140
here ``folder_list``is the list of folders that is present
138
141
139
-
You will see title andid of all the files and folders in root folder of your Google Drive. For more details, take a look at documentation: `File listing made easy`_
142
+
You will see title andid of all the files and folders in root folder of your Google Drive. For more details, refer to the documentation: `File listing made easy`_
0 commit comments