所以我一直在努力解决这个问题。我正在尝试使用curl将文件(〜43mb)上传到我的Google存储桶。以下用于创建请求。
curl -vv -X POST --data-binary @/Users/hg0719/Desktop/G7-Enterprise.ipa \
-H "Authorization: Bearer `gcloud auth print-access-token`" \
-H "Content-Type: application/octet-stream" \
-H "Content-Length: *" \
"https://www.googleapis.com/upload/storage/v1/b/dexflight-v0.appspot.com/o?uploadType=resumable&name=ipa/G7-Enterprise.ipa"
请注意,我指的是此文档:https://cloud.google.com/storage/docs/uploading-objects
我还能够成功地将小文件上传到存储桶(其中url中的uploadType设置为“ media”),但是尝试使用可恢复的上传(uploadType = resumable)并没有运气。
我也尝试过直接在Authorization标头中包含Gcloud访问令牌,但仍会产生相同的确切输出。
哪个会产生此错误消息:
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying 216.58.217.202...
* TCP_NODELAY set
* Connected to www.googleapis.com (216.58.217.202) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
* CAfile: /etc/ssl/cert.pem
CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-ECDSA-CHACHA20-POLY1305
* ALPN, server accepted to use h2
* Server certificate:
* subject: C=US; ST=California; L=Mountain View; O=Google LLC; CN=*.googleapis.com
* start date: Aug 23 10:30:37 2019 GMT
* expire date: Nov 21 10:30:37 2019 GMT
* subjectAltName: host "www.googleapis.com" matched cert's "*.googleapis.com"
* issuer: C=US; O=Google Trust Services; CN=GTS CA 1O1
* SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x7fc76d805000)
> POST /upload/storage/v1/b/dexflight-v0.appspot.com/o?uploadType=resumable&name=ipa/G7-Enterprise.ipa HTTP/2
> Host: www.googleapis.com
> User-Agent: curl/7.54.0
> Accept: */*
> Authorization: Bearer `gcloud auth print-access-token`
> Content-Type: application/octet-stream
> Content-Length: *
>
* Connection state changed (MAX_CONCURRENT_STREAMS updated)!
< HTTP/2 400
< content-type: text/html; charset=UTF-8
< referrer-policy: no-referrer
< content-length: 1555
< date: Thu, 05 Sep 2019 22:47:49 GMT
* HTTP error before end of send, stop sending
<
* HTTP/2 stream 1 was not closed cleanly: PROTOCOL_ERROR (err 1)
* Closing connection 0
* TLSv1.2 (OUT), TLS alert, Client hello (1):
curl: (92) HTTP/2 stream 1 was not closed cleanly: PROTOCOL_ERROR (err 1)
答案 0 :(得分:0)
我建议您尝试使用gsutil -d进行可恢复的上传,并查看调试输出,该输出将显示API请求/响应:
gsutil -d cp bigfile gs://your-bucket/bigfile
然后,您可以将gsutil的操作与您尝试通过curl构造的请求进行比较。