编程语言
首页 > 编程语言> > python-当我在云端硬盘中创建快捷方式时,即使我指定了“ application / vnd.google-apps.drive-sdk”,它的模仿类型也为“ application / octe

python-当我在云端硬盘中创建快捷方式时,即使我指定了“ application / vnd.google-apps.drive-sdk”,它的模仿类型也为“ application / octe

作者:互联网

我正在使用Google App Engine,并试图制作一个将应用程序的快捷方式存储在驱动器中的python应用程序

当我尝试在云端硬盘中创建快捷方式时,请按照文档中的代码进行操作.即使我指定了“ application / vnd.google-apps.drive-sdk”,创建的文件也始终具有模仿类型“ application / octet-stream”.

drive_service = build('drive', 'v2', http=http)

# Insert a shortcut

body = {
  'title': 'shortcut',
  'description': 'description',
  'mimetype': 'application/vnd.google-apps.drive-sdk',
}
file = drive_service.files().insert(body=body).execute()

还有其他人有同样的问题吗?

解决方法:

mimeType区分大小写,大写字母T:

body = {
  'title': 'shortcut',
  'description': 'description',
  'mimeType': 'application/vnd.google-apps.drive-sdk',
}

files().insert() documentation报价:

"mimeType": "A String", # The MIME type of the file. This is only mutable on update when uploading new content. This field can be left blank, and the mimetype will be determined from the uploaded content's MIME type.

标签:google-app-engine,google-drive-api,python
来源: https://codeday.me/bug/20191029/1959069.html