Hi there,
I have a issue with the Google Drive API.
I ran the attached script (download.py) on the Terminal, and it is written "Download 100%". I guessed the file had been downloaded on my computer. However, I cannot find it neither in the Downloads repository, or in any folder at all ...
Do you know what is the exact path / the exact name of files downloaded through Google Drive API ?
Thanks in advance,
Arnaud
There is no python file attached to your post.
I will venture to guess you are using io.ByteIO as in the example. If so, you need to switch to io.FileIO to persist the file
Facing the same issue. Please provide the solution regarding the issue its urgent.
We should probably update the sample to output the file name after download :)
This sample is owned by @grant.
@theacodes Can you link the code sample that is owned by me?
Not sure as the OP never attached the code. :(
I'm not sure where download.py is located.
I've looked in these places:
There are some python samples for downloading here:
https://developers.google.com/drive/api/v3/manage-downloads
And since you've opened this issue, G Suite has samples for our APIs here:
https://github.com/gsuitedevs/python-samples
Feel free to file an issue there or re-opening an issue with specific code and errors and I'll help.
The request to export just dumps the file. I ended up just writing the data to a file:
request = service.files().export(
fileId="myreallylongfileid", mimeType="application/pdf").execute()
with open('myamazing.pdf', 'w') as f:
f.write(request)
The following is the script of download.py. It says 100% downloaded but unable to find file in file explorer.
`
file_id = '0BwwA4oUTeiV1UVNwOHItT0xfa2M'
request = drive_service.files().get_media(fileId=file_id)
fh = io.BytesIO()
downloader = MediaIoBaseDownload(fh, request)
done = False
while done is False:
status, done = downloader.next_chunk()
print "Download %d%%." % int(status.progress() * 100)
`
The file is there but it's in the memory.
So, just replace fh = io.BytesIO() with fh = io.FileIO(filename, 'wb') to save the content to the file.
Thank you I have understood it.
Most helpful comment
The file is there but it's in the memory.
So, just replace
fh = io.BytesIO()withfh = io.FileIO(filename, 'wb')to save the content to the file.