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
.
Same thing if im trying to upload that file via Google Drive interface. It happens sometimes, and i haven't environment with 100% reproducing.
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: Im using this uploader as is, only with cosmetic changes.
I have also seen this 500 error with google analytics a few times and its normaly due to the fact that the server is busy. If I wait a bit and try again it works. Try reading this https://developers.google.com/drive/handle-errors#implementing_exponential_backoff This worked form me with Google Analtyics API, normaly by the time it gets to step 6 its got access again. Haven't tried it with google Drive, but then i havent tried to upload a 25m file before. But i'm betting thats your problem.
OK. I got it.
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).
So i can't filter files by mime-type anymore.
I tried to filter files by keyword title, but looks like titles doesn't contain extension, but in response item titles contain extension.
So i have to filter my files not by mime-type or by title, but by fullText keyword.
Conclusion:
{"error":{"errors":[{"domain":"global","reason":"backendError","message":"Backend Error"}],"code": 500,"message": "Backend Error"}}
I think this would be related to raw photo files, because DRIVE tries to convert them to JPG as is done in Google+, unless you specify convert=false. You should specify in your upload API to not convert that files.
This second post says that it will allow you to preview the file up to 25MB, this size limitation could be related with your troubles. Maybe you could try to upload another photo with less than that size to ensure it's not this the limitation.