【发布时间】:2015-12-05 15:09:01
【问题描述】:
可能这是一个重复的问题,但我没有得到任何成功的答案。
我正在尝试将一些文件上传到谷歌驱动器。它已成功上传,但文件名仍为“无标题”。下面是我在 curl 和 python 请求中尝试过的内容
卷曲
curl -X POST -H 'Content-Type:*/*'
-H 'Authorization: Bearer <The access token>'
-H 'Content-Length:125'
--upload-file 'foo.txt'
'https://www.googleapis.com/upload/drive/v2/files?uploadType=multipart'
-d '{"title":"foo.txt","description":"test file"}'
在这里尝试使用Content-Type:multipart/related; boundary="foo_bar_baz" 时,它的抛出错误说“使用多部分”,而只尝试“多部分”,它说使用“/”。文件上传的任何方式,但名称为“未命名”
以下是python请求中的相同内容:
upload_files = requests.post(
'https://www.googleapis.com/upload/drive/v2/files?uploadType=multipart',
headers={'Authorization':'Bearer {}'.format(access_token),
'Content-Type':'*/*',
'Content-Length':file_size},
data={"title":file_name,
"mimeType": "*/*",
"parents": [{"id":"root"}],
"description": "mypdf.pdf"},
files={'file':file},
)
请不要投反对票,如果我犯了一个愚蠢的错误,请发表评论。我会查一下。在这里,在我的情况下,我无法使用 Google Drive 客户端 非常感谢您抽出时间检查我的问题。
【问题讨论】:
标签: python curl google-drive-api google-drive-realtime-api