Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python google drive API download, where is file?

I used the python code found here to download a file on google drive: https://developers.google.com/drive/v3/web/manage-downloads I have this scope: https://www.googleapis.com/auth/drive everything seems to work, I read:

Download 35%.
Download 71%.
Download 100%.

but where is the file? in the same directory as the python file, there is nothing, neither the root, nor in the home ... you have ideas? or alternatively how can I debug?

like image 214
michelle.70 Avatar asked Jan 06 '23 03:01

michelle.70


1 Answers

Example in Google doc uses

fh = io.BytesIO()

so it reads data into memory and it doesn't save on disk.

You have to save it using (for example)

my_file = open(filename, 'wb')
my_file.write(fh)
my_file.close()

EDIT: information for others - as @michelle.70 found - we can use

fh = io.FileIO(filename, 'wb') 

instead of fh = io.BytesIO() and it will save it in file.

It should also work if you use normal open()

fh = open(filename, 'wb')

Don't forget to close fh (in both methods).

like image 121
furas Avatar answered Jan 15 '23 12:01

furas