我正在尝试以多个块将文件上传到谷歌存储但签名的 URL。
以下是我正在遵循的步骤:
- 使用 Node.js 创建可恢复上传 URL。
示例网址:https://www.googleapis.com/upload/storage/v1/b/MYBUCKET/o?name=sdk2.txt&uploadType=resumable&upload_id=AEnB2UrmFY9CKwkHFxsYdT71LcWa0zUVjG6iYfr9mHiwsIaG3c1goFiVURUPz6KFTIhtywndse00XaOkH7ftXPf82S7bNVRhPg
- 启动可恢复的上传会话:
POST https://www.googleapis.com/upload/storage/v1/b/MYBUCKET/o?name=sdk2.txt&uploadType=resumable&upload_id=AEnB2UrmFY9CKwkHFxsYdT71LcWa
使用这些标题:
Content-Type:text/plain
name:sdk2.txt
Content-Length:0
x-goog-resumable:start
HTTPS 响应:200 OK
- 发送第一个块:
PUT https://www.googleapis.com/upload/storage/v1/b/MYBUCKET/o?name=sdk2.txt&uploadType=resumable&upload_id=AEnB2UrmFY9CKwkHFxsYdT71LcWa0zUVjG6iYfr9mHiwsIaG3c1goFiVURUPz6KFTIhtywndse00XaOkH7ftXPf82S7bNVRhPg
使用这些标题:
Content-Type:text/plain
name:sdk2.txt
Content-Length: 262144
Content-Range: bytes 0-262143/331886
HTTPS 响应:200 OK
带有数据:
{
"kind": "storage#object",
"id": "MYBUCKET/sdk2.txt/1490608714382301",
"selfLink": "https://www.googleapis.com/storage/v1/b/testupload-sdk/o/sdk2.txt",
"name": "sdk2.txt",
"bucket": "MYBUCKET",
"generation": "1490608714382301",
"metageneration": "1",
"timeCreated": "2017-03-27T09:58:34.164Z",
"updated": "2017-03-27T09:58:34.164Z",
"storageClass": "MULTI_REGIONAL",
"timeStorageClassUpdated": "2017-03-27T09:58:34.164Z",
"size": "0",
"md5Hash": "1B2M2Y8AsgTpgAmY7PhCfg==",
"mediaLink": "https://www.googleapis.com/download/storage/v1/b/MYBUCKET/o/sdk2.txt?generation=1490608714382301&alt=media",
"crc32c": "AAAAAA==",
"etag": "CN33rZe29tICEAE="
}
根据文档,上述响应应该是308
而不是200 OK
。
这些 API 调用我做错了什么?