久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 Google Drive Java API 中設(shè)置 uploadType

Setting uploadType in Google Drive Java API(在 Google Drive Java API 中設(shè)置 uploadType)
本文介紹了在 Google Drive Java API 中設(shè)置 uploadType的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我遇到了與 這個和這個 但在 Java 域中.這個問題也涵蓋了我想要的,但由于沒有答案,我想我會在這里問它,并提供更多細(xì)節(jié).

I'm having the same problem as this and this but in the Java domain. This question also covers what I want but since no answers have been forthcoming I thought I'd ask it here, with a little more detail.

我主要是通過編寫 Java 應(yīng)用程序來將文件備份到 Google Drive.正如其他人發(fā)現(xiàn)的那樣,內(nèi)部服務(wù)器錯誤 500"失敗是上傳的一個非常常見的問題,但對于小文件,實現(xiàn) 推薦的指數(shù)退避和重試 工作正常.然而,對于大文件(任何超過幾 MB 的文件),失敗率高得令人無法接受.在某些情況下,我的故障率遠(yuǎn)遠(yuǎn)超過 50%,這使得任何長時間的備份工作實際上都變得不可能.

I'm most of the way through writing a Java application to back up files to Google Drive. As others have found, 'internal server error 500' failures are a pretty common problem with uploads, but for small files, implementing the recommended exponential back-off and retry works okay. For large files, however, (anything over a few MB) the failure rate is unacceptably high. In some cases I'm getting well over 50% failure rate, which makes any long backup job effectively impossible.

使用 Google Drive v2 API 插入(上傳)文件時,文檔明確說明 可以使用三種上傳類型:簡單、多部分和可恢復(fù).通過向端點 URL 添加參數(shù)來指定上傳類型.顯然,我追求的是可恢復(fù)上傳類型.

When inserting (uploading) a file using the Google Drive v2 API, the documentation clearly states that three upload types are available: simple, multipart and resumable. The upload type is specified by adding a parameter to the endpoint URL. Clearly, what I'm after is the resumable upload type.

似乎沒有使用 API 設(shè)置此 up??loadType 參數(shù)的方法.有一個方法調(diào)用來設(shè)置每個可選參數(shù)(詳見這里),但不是一種將uploadType設(shè)置為可恢復(fù)的方法.沒有代碼片段,沒有文檔,什么都沒有.

There appears to be no method to set this uploadType parameter using the API. There's a method call to set every optional parameter (as detailed here), but not a sniff of a way to set uploadType to resumable. No code snippets, no documentation, no nothing.

有點令人困惑的是,還有一個似乎是不相關(guān)的分塊"媒體上傳模式,這是默認(rèn)設(shè)置,我實際上通過調(diào)用 request.getMediaHttpUploader().setDirectUploadEnabled(true) 在我的應(yīng)用程序中禁用了它),因為它似乎對上傳的可靠性沒有任何影響,無論塊大小設(shè)置為多少,它都會大大減慢上傳速度.

Somewhat confusingly, there is also what appears to be an unrelated 'chunked' media upload mode, which is the default and which I've actually disabled in my application by calling request.getMediaHttpUploader().setDirectUploadEnabled(true), since it appears to make no difference whatsoever to the reliability of an upload, no matter what the chunksize is set to, and it hugely slows uploads down.

我即將繞過 API 并手動構(gòu)建請求,但我真的很想知道是否有其他人首先遇到/解決了這個問題.這是一個如此明顯的遺漏,我不敢相信很多人以前沒有遇到過.

I'm on the verge of circumventing the API and building the requests manually, but I'd really like to know if anyone else has encountered/solved this first. It's such a glaring omission that I can't believe lots of folk haven't encountered it before.

大家干杯.

大衛(wèi).

推薦答案

簡答:

當(dāng)您使用 Google Drive java 客戶端 API 時,傳遞給 MediaHttpUploader 的可恢復(fù)上傳的 URI 似乎與 Google Drive API V2.所以實際上默認(rèn)情況下,Google Drive Java 客戶端 API 已經(jīng)在使用可恢復(fù)上傳.

Short answer:

The URI passed to MediaHttpUploader's resumable upload when you use the Google Drive java client API seems to be the same as the one proposed on Google Drive API V2. So actually by default the Google Drive Java client API is already using the resumable upload.

在 Google Drive Java API 客戶端中一路跟蹤代碼后

After tracing the code in Google Drive Java API client all the way from

com.google.api.services.drive.Drive

->com.google.api.services.drive.DriveRequest

->com.google.api.client.googleapis.services.AbstractGoogleJsonClientRequest

您會發(fā)現(xiàn)Drive的構(gòu)造函數(shù)將URI傳遞給DriveRequest,它也將變量uriTemplate傳遞給AbstractGoogleJsonClientRequest.最后,AbstractGoogleJsonClientRequest 使用 buildHttpRequestUrl() 生成 Google Drive API 參考.此 URI 存儲在 AbstractGoogleJsonClientRequest 中的變量 httpRequestUrl 中.httpRequestUrl 然后將被傳遞給 上傳者的上傳方法.這 方法 默認(rèn)情況下(directUploadEnabled 默認(rèn)為 false)將使用可恢復(fù)上傳而不是直接上傳.

You will find that Drive's constructor passes the URI to DriveRequest, which also passes the variable uriTemplate to AbstractGoogleJsonClientRequest. And finally AbstractGoogleJsonClientRequest uses buildHttpRequestUrl() to generate the resumable URI proposed in Google Drive API reference. This URI is stored in the variable httpRequestUrl in AbstractGoogleJsonClientRequest. httpRequestUrl will then be passed to uploader's upload method. This method by default (directUploadEnabled defaults to false) will use the resumable upload instead of direct upload.

這篇關(guān)于在 Google Drive Java API 中設(shè)置 uploadType的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Upload progress listener not fired (Google drive API)(上傳進(jìn)度偵聽器未觸發(fā)(Google 驅(qū)動器 API))
Save file in specific folder with Google Drive SDK(使用 Google Drive SDK 將文件保存在特定文件夾中)
Google Drive Android API - Invalid DriveId and Null ResourceId(Google Drive Android API - 無效的 DriveId 和 Null ResourceId)
Google drive api services account view uploaded files to google drive using java(谷歌驅(qū)動api服務(wù)賬戶查看上傳文件到谷歌驅(qū)動使用java)
Google Drive service account returns 403 usageLimits(Google Drive 服務(wù)帳號返回 403 usageLimits)
com.google.api.client.json.jackson.JacksonFactory; missing in Google Drive example(com.google.api.client.json.jackson.JacksonFactory;Google Drive 示例中缺少)
主站蜘蛛池模板: 夜夜操天天艹 | 久久久久久蜜桃一区二区 | www亚洲精品 | 国产精品久久久久久久久久了 | 天天色天天射天天干 | 久久逼逼| 麻豆changesxxx国产 | 男人的天堂中文字幕 | 免费久久99精品国产婷婷六月 | 欧美亚洲国产一区二区三区 | 国产精品精品 | 中文字幕精品视频 | 亚洲性网 | 欧美激情网站 | 日韩欧美国产精品综合嫩v 一区中文字幕 | 午夜精品久久久久久久久久久久久 | 天堂网中文 | 亚洲精品国产电影 | 欧美日韩高清一区二区三区 | 色狠狠桃花综合 | 国产99久久精品一区二区永久免费 | 国产一区二区三区 | 欧美三区视频 | 国产乱码精品1区2区3区 | 免费看国产一级特黄aaaa大片 | 日韩综合网 | 欧美日日日日bbbbb视频 | av一级久久 | 国产精品久久久久久二区 | 99精品一区二区三区 | 日韩欧美在线免费 | 先锋av资源网 | 亚洲欧美一区二区三区国产精品 | 免费在线黄 | h肉视频| 欧美激情一区二区三区 | 国产精品高潮呻吟久久av黑人 | 成人综合视频在线 | 在线观看www视频 | 日韩国产专区 | 欧洲精品一区 |