'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?



Solution 1:[1]

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).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1