Skip to content

Figure out how to do browser-based uploading, and document it well. #641

@jgeewax

Description

@jgeewax

So there's this concept of "browser-based uploads" which basically is the following process:

  1. Client sends the server an (untrusted) policy document (basically says "I'm going to upload file which is 10mb and has metadata = {...}).
  2. Server gets this request, validates it, and if it likes it, sends back a signature (basically says "SGTM, here's my stamp of approval").
  3. Client is able to upload exactly that data directly to Cloud Storage, it's "credentials" for this single request being the policy document (and the signature).

So... a couple of questions:

  1. Can we even use gcloud-node in the client-side of a web-app?
  2. If so, we need a simple way of creating typical policy documents (as well as weird ones).
  3. Then we need a way of generating a signature (server-side) for a policy document.
    Note that we're not wiring together any RPCs or anything. Just providing a method that takes a policy and spits back a signature for the user to serialize and send around however they want.
  4. Then we need a way of calling upload (or similar) using the policy document and signature.

The code I'm expecting here would look like...

Server-side:

bucket.signPolicy(policy, function(signature) {
  // The signature can be serialized or whatever else we want now.
});

Client-side:

var policy = bucket.policy({ /* Lots of configuration here... */ });
$.post({ /* Send the policy up to the method above */ }, function(response) {
  // Create an HTML form (?) that has a field called signature = response.data ?
});

/cc @Capstan

Metadata

Metadata

Labels

api: storageIssues related to the Cloud Storage API.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions