![]() ![]() We will use the MediaIoBaseDownload class to receive the file from the server and write it in memory with the BytesIO object. Then, we will use a BytesIO object which will write the file to the memory. Now, we will make a request to the Drive service to get us the file with the given id. First is the id of that file in Drive and second is the name you want it to be saved as. Now, Inside the FileDownload function, we will write the code to download a file. ![]() Each item of the list contains an id and name for that file in Google Drive. Once the access is granted, it will connect to the drive and fetch a list of files in the Google Drive storage for that account and print that list. if it doesn’t exist or is invalid, the script will open up a new tab in the browser and ask for access to Google Drive. We may have to refresh the token if it’s been a long time since the token was used. If it exists, that means we have the access to the Google Drive storage and we don’t need to ask for it again. Inside the constructor, we will check if the file ‘ token.pickle’ exists or not. Then we will define a class DriveAPI with a constructor and two functions for uploading and downloading files. Getting Startedįirst of all, we will import the required libraries. Please make sure the file credentials.json is in the same directory.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2022
Categories |