我正在尝试将 .xlsx 文件上传到谷歌驱动器。我可以上传它。但是当我们尝试在 Drive 中打开同一个文件时,它必须使用 Google Sheets 打开。因此,它会创建一个同名的新文件并占用驱动器空间。
我想我需要在上传时更改 MimeType。
我尝试过的是:
file = drive.CreateFile({"parents": [{"kind": "drive#fileLink", "id": FolderID}]
,'title': fileName
,'mimeType':'application/vnd.ms-excel'})
file.SetContentFile('12dec2018.xlsx')
file.Upload()
Run Code Online (Sandbox Code Playgroud)
我也试过这个
'mimeType':'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
Run Code Online (Sandbox Code Playgroud)
在 Google文档中
我找到了另一个 MimeType
'mimeType':'application/vnd.google-apps.spreadsheet'
Run Code Online (Sandbox Code Playgroud)
但它给了我错误
ApiRequestError:https://www.googleapis.com/upload/drive/v2/files?uploadType=resumable&alt=json 返回“提供的 MIME 类型无效”>
请建议我如何才能达到理想的结果。