问题描述
我正在尝试通过 REST API(可恢复上传)将我的文件上传到 Google Drive.一切看起来都很好(XMLHttpRequest
触发 onprogress
和 onload
事件),但在它之后(onload 触发)Google Drive PUT 请求失败,500内部服务器错误
.文件未出现在我的 Google Drive 文件夹中.错误 500 来自 xhr.onload
,而不是 xhr.onerror
.
Im trying to upload my files to Google Drive via REST API (resumable upload).Everything looks good (XMLHttpRequest
triggers onprogress
and onload
events), but after it (onload triggered) Google Drive PUT request fail with 500 Internal Server Error
. File not appears in my Google Drive folder. Error 500 comes in xhr.onload
, not in xhr.onerror
.
如果我尝试通过 Google Drive 界面上传该文件,情况也是如此.它有时会发生,而且我没有 100% 再现的环境.
Same thing if im trying to upload that file via Google Drive interface. It happens sometimes, and i haven't environment with 100% reproducing.
文件类型 Adobe .DNG 或 Canon .CR2 和文件大小 ~28MB.
Filetype Adobe .DNG or Canon .CR2 and filesize ~28MB.
我做错了什么?文件类型或文件是否存在已知错误或限制?
What im doing wrong? Is it known bug or limitations to filetypes or file?
可能的原因:文件大小限制、文件类型限制,或者我的令牌在我的文件上传时已过期?
Possible reasons: filesize limitations, filetype limitations, or maybe my token is expires while my file is uploading?
UPD:我按原样使用这个上传器,只是做了外观改动.
UPD: Im using this uploader as is, only with cosmetic changes.
推荐答案
好的.我明白了.
使用 Content-Type == "application/octet-stream" 成功上传文件.看起来像带有 MIME 类型文件的 GoogleDrive 端的错误.在这种情况下,我的原始文件(DNG、CR2、NEF 等)以错误的 MIME 类型存储在 GoogleDrive 中(因此这些文件没有预览).
Files uploads successfully with Content-Type == "application/octet-stream". Looks like bug on GoogleDrive side with mime-type'd files.In this scenario my raw files (DNG, CR2, NEF etc.) stores in GoogleDrive with incorrect mime-type (as a result there is no preview for these files).
所以我不能再按 MIME 类型过滤文件了.
So i can't filter files by mime-type anymore.
Query string = (mimeType = 'image/x-adobe-dng' or mimeType = 'image/x-canon-cr2' or mimeType = 'image/x-nikon-nef').
我尝试按关键字标题过滤文件,但看起来标题不包含扩展名,但响应项目标题包含扩展名.
I tried to filter files by keyword title, but looks like titles doesn't contain extension, but in response item titles contain extension.
Query string = (title contains '.dng' or title contains '.cr2' or title contains '.nef').
所以我不能按 mime 类型或标题过滤我的文件,而是按 fullText 关键字.
So i have to filter my files not by mime-type or by title, but by fullText keyword.
Query string = (fullText contains '.dng' or fullText contains '.cr2' or fullText contains '.nef').
结论:
- GoogleDrive 上传程序会检查 Content-Type,即使转换选项设置为 false.
- GoogleDrive 不时会因该转换而失败.
- 上传器在 Content-Type == 'application/octet-stream' 下工作正常.
- GoogleDrive 查询字符串关键字标题不包含文件扩展名,但响应标题有扩展名.
- GoogleDrive 查询字符串关键字fullText 包含带扩展名的文件名(对于文本文件来说速度不是很快).
- 要测试您的请求,您可以使用此工具https://developers.google.com/drive/v2/reference/files/list 在页面末尾.
- GoogleDrive API 不时崩溃并显示 HTTP 状态500 内部服务器错误:
- GoogleDrive uploader checks Content-Type, even if convert option is set to false.
- GoogleDrive fails from time to time with this convertation.
- Uploader works fine with Content-Type == 'application/octet-stream'.
- GoogleDrive query string keyword title doesn't contain file extension, but in response titles have extension.
- GoogleDrive query string keyword fullText contains filename with extension (mb its not very fast for text files).
- To test your request you can use this tool https://developers.google.com/drive/v2/reference/files/list in the end of page.
- GoogleDrive API crashes from time to time with HTTP status 500 Internal Server Error:
{"error":{"errors":[{"domain":"global","reason":"backendError","message":"Backend Error"}],"code": 500,"message": "后端错误"}}
这篇关于Google Drive 上传文件大小限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!