下面的StackOverflow问题似乎在这个问题上被广泛引用。RE:通过API向Google Drive插入文件
How do I add/create/insert files to Google Drive through the API?
这些简单的指示失败对我来说。这是我送谷歌:
POST https://www.googleapis.com/upload/drive/v2/files
Authorization: Bearer ya29.AHES6ZRO8SLGjreb1DbNju62WF-AHES6ZRO8SLGjreb1DbNju62
Content-Length: 347
Content-Type: multipart/mixed; boundary="1366986113131560"
--1366986113131560
Content-Type: application/json
{"mimeType":"text/plain","title":"hi.txt","parents":[{"id":"0BxnfVWt9egI_VDJnbFBpZDExTmM"}]}
--1366986113131560
Content-Type: text/plain
setPendingSave
loadSegments
setSequence
addSegment
setspanformat
setspanformat
hidespanformat
setspanformat
setspanformat
hidespanformat
--1366986113131560--
当我提出这一点,谷歌与错误提示信息:
多部分内容有太多的非媒体部分
我不想痛打这一点,但它是很好的证明,API的工作原理,而不必依赖谷歌图书馆。
由于意外,我再次使用Mime-Type“image/jpeg”进行了测试,上传成功。 “text/plain”不是有效的文件类型吗? – 2013-04-26 15:23:52
此外,在子部分标题中设置“Content-Transfer-Encoding”值会导致消息“格式错误的多部分主体”。 – 2013-04-26 15:56:56