Я работаю на стороне клиента, чтобы получить информацию о файле с библиотекой OkHttp
. Я пытаюсь получить его с Google Диска, используя этот код:
val url = "https://doc-0g-0c-docs.googleusercontent.com/docs/securesc/ha0ro937gcuc7l7deffksulhg5h7mbp1/uqi0f95jaa3cp9t78aqcmfg352flft7d/1554019200000/16042636045718966916/*/1vjNTRlUeMXFx9_H3IE7jw5yBKV0F3bIO?e=download"
val request = Request.Builder().url(url)
.header("User-Agent", "Mozilla/5.0 (Linux; Android 7.0) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Focus/2.2 Chrome/61.0.3163.98 Mobile Safari/537.36")
.header("Origin", "*")
.header("Access-Control-Request-Method", "POST")
.header("Access-Control-Request-Headers", "Accept, Content-Length")
.build()
OkHttpClient().newCall(request).execute().use { response ->
println(response.headers()) // print all headers
println("------------------------------")
println("File size: " + response.header("Content-Length"))
println("Response code: " + response.code())
}
Но Content-Length
не найден в списке заголовков:
X-GUploader-UploadID: AEnB2UriGmFlC7rQhj22k_7ABtzFKZzRsU4WMlIvPXmfIzaHnfrdnk6sENez7kMsE
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: false
Access-Control-Allow-Headers: Accept, Accept-Language, Authorization, Cache-Control, Content-Disposition, Content-Encoding, Content-Language, Content-Length, Content-MD5, Content-Range, Content-Type, Date, GData-Version, google-cloud-resource-prefix, Host, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, Origin, OriginToken, Pragma, Range, Slug, Transfer-Encoding, Want-Digest, x-chrome-connected, X-ClientDetails, X-Client-Version, X-Firebase-Locale, X-GData-Client, X-GData-Key, X-Goog-AdX-Buyer-Impersonation, X-Goog-Api-Client, X-Goog-AuthUser, X-Goog-PageId, X-Goog-Encode-Response-If-Executable, X-Goog-Correlation-Id, X-Goog-Request-Info, X-Goog-Request-Reason, X-Goog-Experiments, x-goog-iam-authority-selector, x-goog-iam-authorization-token, X-Goog-Spatula, X-Goog-Upload-Command, X-Goog-Upload-Content-Disposition, X-Goog-Upload-Content-Length, X-Goog-Upload-Content-Type, X-Goog-Upload-File-Name, X-Goog-Upload-Header-Content-Length, X-Goog-Upload-Offset, X-Goog-Upload-Protocol, X-Goog-Visitor-Id, X-Goog-FieldMask, X-HTTP-Method-Override, X-JavaScript-User-Agent, X-Pan-Versionid, X-Proxied-User-IP, X-Origin, X-Referer, X-Requested-With, X-Upload-Content-Length, X-Upload-Content-Type, X-Use-HTTP-Status-Code-Override, X-Ios-Bundle-Identifier, X-Android-Package, X-Ariane-Xsrf-Token, X-YouTube-VVT, X-YouTube-Page-CL, X-YouTube-Page-Timestamp, X-Goog-Meeting-Botguardid, X-Goog-Meeting-Debugid, X-Goog-Meeting-Token, X-Client-Data, X-Sfdc-Authorization, MIME-Version, Content-Transfer-Encoding
Access-Control-Allow-Methods: GET,OPTIONS
Content-Type: video/mp4
Content-Disposition: attachment;filename="some-name.mp4"
Date: Sun, 31 Mar 2019 14:54:53 GMT
Expires: Sun, 31 Mar 2019 14:54:53 GMT
Cache-Control: private, max-age=0
X-Goog-Hash: crc32c=6SCARA==
Transfer-Encoding: chunked
Server: UploadServer
Alt-Svc: quic=":443"; ma=2592000; v="46,44,43,39"
------------------------------
File size: null
Response code: 200
Я прочитал много сообщений о CORS, но я нашел только межсерверный код. Я пытаюсь получить информацию о файле со стороны клиента, то есть Android. Итак, вы знаете, чтобы получить его?
Заранее спасибо.