Using Google Cloud Storage, I'd like to pass a client the necessary information to do a resumable upload. Is this possible?
问题:
回答1:
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:
- Client requests a signature so it can do a PUT
- Your server creates and returns a signed
URL
using the method described here - Client does a PUT with the returned
URL
The resumable workflow looks like this:
- Client requests a signature so it can do a PUT
- Your server does creates and returns a signed
URL
using the method described here - Your server makes a POST request to initiate the resumable upload as described here
- Your server returns both the
URL
and theUpload ID
to the client - Client does one or more PUTs using the provided
URL
andUpload ID
回答2:
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:
- Client requests an upload so it can do a PUT
- Your server makes a POST request to initiate the resumable upload.
- Your server returns the upload id to the client.
- Client does a PUT to upload the file using the provided upload id.