Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I do a resumable upload with a Google Cloud Storage signed URL?

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

like image 616
Benson Avatar asked Jan 28 '13 19:01

Benson


2 Answers

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
like image 75
Benson Avatar answered Oct 13 '22 18:10

Benson


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.
like image 5
d_inevitable Avatar answered Oct 13 '22 18:10

d_inevitable