【发布时间】:2021-09-03 11:56:43
【问题描述】:
我正在尝试将图像上传到共享驱动器中的文件夹。我设法在我的云端硬盘上做到这一点,但是当我试图在共享云端硬盘上实现这一点时,我收到以下错误:
{
"error": {
"code": 404,
"message": "File not found: 1ZQuuXVDx3I5rs6OnH8WvbWfo6HplnfW8.",
"errors": [
{
"locationType": "parameter",
"domain": "global",
"message": "File not found: 1ZQuuXVDx3I5rs6OnH8WvbWfo6HplnfW8.",
"reason": "notFound",
"location": "fileId"
}
]
}
}
这让我现在发疯了,因为我已经多次阅读文档但找不到解决方案。我在 Android 上尝试过使用Retrofit、Postman 甚至是 Google 提供的 OAuth2 Playground。
请求就是这个,从OAuth2 Playground复制粘贴:
POST /upload/drive/v3/files?uploadType=multipart HTTP/1.1
Host: www.googleapis.com
Content-length: 50295
Content-type: multipart/related; boundary="===============323232404548=="
Authorization: Bearer ya29.a0AfH6SMBHmEo0Q9-8dXhhCY7wGrTj9PsFTCd0YUdLtyGJSfdO
--===============323232404548==
Content-type: application/json
{
"supportsAllDrives": true,
"driveId":"0APRAdsf3Sdfsk9PVA",
"name":"test.jpeg",
"parents":[
"1ZQuuXVDx3I5rs6OnH8WvbWfo6HplnfW8"
]
}
--===============323232404548==
Content-type: image/jpeg
究竟是什么问题?我也尝试在请求的标头中使用driveId 和supportsAllDrives。
非常感谢任何帮助。我关注的链接:
https://developers.google.com/drive/api/v3/manage-uploads#multipart 和 https://developers.google.com/drive/api/v3/reference/files/create
【问题讨论】:
标签: android google-drive-api retrofit2 google-drive-android-api google-drive-shared-drive