googlearchive / PyDrive

Google Drive API Python wrapper library
Other
1.31k stars 273 forks source link

FileNotDownloadableError: No downloadLink/exportLinks for mimetype found in metadata #163

Open rehema-HM opened 5 years ago

rehema-HM commented 5 years ago

I want to download a zip file and extract it but am getting errors here is mmy code `%cd ~/Mask_RCNN

fileId = '1EKGmB8iV1mN6Itxrc6PD2Cw2k01r6A7h'

import os from zipfile import ZipFile from shutil import copy from pydrive.auth import GoogleAuth from pydrive.drive import GoogleDrive from google.colab import auth from oauth2client.client import GoogleCredentials

os.makedirs('dataset') os.chdir('dataset')

auth.authenticate_user() gauth = GoogleAuth() gauth.credentials = GoogleCredentials.get_application_default() drive = GoogleDrive(gauth)

fileName = fileId + '.zip' downloaded = drive.CreateFile({'id': fileId}) downloaded.GetContentFile(fileName) ds = ZipFile(fileName) ds.extractall() os.remove(fileName) print('Extracted zip file ' + fileName)`

This is the error`/root/Mask_RCNN

FileNotDownloadableError Traceback (most recent call last)

in () 22 fileName = fileId + '.zip' 23 downloaded = drive.CreateFile({'id': fileId}) ---> 24 downloaded.GetContentFile(fileName) 25 ds = ZipFile(fileName) 26 ds.extractall() 2 frames /usr/local/lib/python3.6/dist-packages/pydrive/files.py in FetchContent(self, mimetype, remove_bom) 263 else: 264 raise FileNotDownloadableError( --> 265 'No downloadLink/exportLinks for mimetype found in metadata') 266 267 if mimetype == 'text/plain' and remove_bom: FileNotDownloadableError: No downloadLink/exportLinks for mimetype found in metadata` ps: I am new to python
HFulcher commented 4 years ago

This is an old issue but I encountered this problem (for the same script as well). I resolved it fairly easily.

You are likely encountering this issue if you are looking at the file ID in the browser bar. This is for the folder no the .zip file. To find the file ID for the .zip file, right click on the .zip, click "get shareable link", in the link will be the file ID.