我正在尝试使用 Google Cloud Storage JSON API 生成可恢复的会话 uri。按照文档,我将以下 curl 命令放在一起,仅满足所需的参数
curl \
-X POST \
-H "Content-Length: 1000000" \
-d "uploadType=resumable&name=cat.jpg" \
https://www.googleapis.com/upload/storage/v1/b/my-bucket/o
但是,这会超时并且服务器永远不会响应。请注意,Content-Type
仅当还发送文件元数据时才需要。我也尝试过添加元数据和相关数据,但这也失败了。
在文档中的示例请求中,有一个Authorization: Bearer [YOUR_AUTH_TOKEN]
步骤中未提及的标头。我也尝试过使用应用程序的 api 密钥添加它,但这也会超时。
存储桶上的 ACL 已设置为所有用户可写。未配置 CORS。
谁能指出我哪里出错了?
curl详细输出是
* Hostname was NOT found in DNS cache
* Trying 216.58.208.138...
* Connected to www.googleapis.com (216.58.208.138) port 443 (#0)
* successfully set certificate verify locations:
* CAfile: none
CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server key exchange (12):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using ECDHE-ECDSA-AES128-GCM-SHA256
* Server certificate:
* subject: C=US; ST=California; L=Mountain View; O=Google Inc; CN=*.googleapis.com
* start date: 2017-10-24 08:38:00 GMT
* expire date: 2017-12-29 00:00:00 GMT
* subjectAltName: www.googleapis.com matched
* issuer: C=US; O=Google Inc; CN=Google Internet Authority G2
* SSL certificate verify ok.
> POST /upload/storage/v1/b/aits-resumables-test/o HTTP/1.1
> User-Agent: curl/7.35.0
> Host: www.googleapis.com
> Accept: */*
> Content-Length: 1000000
> Content-Type: application/json; charset=UTF-8
>
* upload completely sent off: 33 out of 33 bytes