I am creating a flask application in python that needs to move local files to google drive using the Pydrive library and Google Drive API. All goes well until I upload the file and then I get the following error:
pydrive.files.ApiRequestError: <HttpError 404 when requesting None returned "File not found: 2". Details: "[{'domain': 'global', 'reason': 'notFound', 'message': 'File not found: 2', 'locationType': 'other', 'location': 'file'}]">
My code is as follows.
gauth = GoogleAuth()
gauth.LocalWebserverAuth()
drive = GoogleDrive(gauth)
if file_ext == ".jpg":
mimeType = "image/jpeg"
elif file_ext == ".png":
mimeType = "image/png"
elif file_ext == ".gif":
mimeType = "image/gif"
elif file_ext == ".mp4":
mimeType = "video/mp4"
elif file_ext == ".mp3":
mimeType = "audio/mpeg"
elif file_ext == ".wav":
mimeType = "audio/wav"
elif file_ext == ".bmp":
mimeType = "image/bmp"
elif file_ext == ".docx":
mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
elif file_ext == ".txt":
mimeType = "text/plain"
elif file_ext == ".MOV":
mimeType = "video/quicktime"
elif file_ext == ".pdf":
mimeType = "application/pdf"
file1 = drive.CreateFile({"mimeType": mimeType, "parents": [{"kind": "drive#fileLink", "id": uniqueID}]}) #uniqueID is defined earlier on based on the fileID in my database
file1.SetContentFile(filename)
file1.Upload()
Any help would be greatly appreciated as the project is for college and I am not the most experienced in flask, let alone PyDrive!
Thanks :)