This is the code written according to the official documentation, I do not know which side went wrong

Viewed 46
def downloadFile():
    file_id = ''  # file id
    request = drive_service.files().get_media(fileId=file_id)
    fh = io.FileIO('hello.txt', 'wb')
    downloader = MediaIoBaseDownload(fh, request)
    done = False
    while done is False:
        status, done = downloader.next_chunk()
        print("Download %d%%." % int(status.progress() * 100))

# Setup the Drive v3 API
SCOPES = 'https://www.googleapis.com/auth/drive.file'
store = file.Storage('credentials.json')
creds = store.get()
if not creds or creds.invalid:
    flow = client.flow_from_clientsecrets('client_secret_2.json', SCOPES)
    creds = tools.run_flow(flow, store)
drive_service = build('drive', 'v3', http=creds.authorize(Http()))

if __name__ == '__main__':
    downloadFile()

This can download files just uploaded via google drive api, but can't download other This problem bothered me for two days

0 Answers
Related