Can I do a resumable upload with a Google Cloud St

2020-02-08 04:51发布

Using Google Cloud Storage, I'd like to pass a client the necessary information to do a resumable upload. Is this possible?

2条回答
叼着烟拽天下
2楼-- · 2020-02-08 05:32

Yes, this is possible.

With a server that has authenticated to the Cloud Storage service and a client it wishes to grant access to, the typical signed URL upload workflow looks like this:

  1. Client requests a signature so it can do a PUT
  2. Your server creates and returns a signed URL using the method described here
  3. Client does a PUT with the returned URL

The resumable workflow looks like this:

  1. Client requests a signature so it can do a PUT
  2. Your server does creates and returns a signed URL using the method described here
  3. Your server makes a POST request to initiate the resumable upload as described here
  4. Your server returns both the URL and the Upload ID to the client
  5. Client does one or more PUTs using the provided URL and Upload ID
查看更多
Juvenile、少年°
3楼-- · 2020-02-08 05:34

I just found this note on the docs here:

Note: If your users are only uploading resources (writing) to an access-controlled bucket, you can use the resumable uploads functionality of Google Cloud Storage, and avoid signing URLs or requiring a Google account. In a resumable upload scenario, your (server-side) code authenticates and initiates an upload to Google Cloud Storage without actually uploading any data. The initiation request returns an upload ID, which can then be used in a client request to upload the data. The client request does not need to be signed because the upload ID, in effect, acts as an authentication token. If you choose this path, be sure to transmit the upload ID over HTTPS.

So basically you don't need a signed url. The upload ID would be enough. The procedure would be as follows:

  1. Client requests an upload so it can do a PUT
  2. Your server makes a POST request to initiate the resumable upload.
  3. Your server returns the upload id to the client.
  4. Client does a PUT to upload the file using the provided upload id.
查看更多
登录 后发表回答