GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Figure out how to do browser-based uploading, and document it well. · Issue #641 · googleapis/google-cloud-node

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

New issue
Copy link
New issue
Copy link
Closed
Closed
Figure out how to do browser-based uploading, and document it well.#641
Copy link
Assignees
stephenplusplus
Labels
api: storageIssues related to the Cloud Storage API.

Description

@jgeewax
jgeewax
opened on Jun 6, 2015
Issue body actions

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

Activity

Next
  1. jgeewax
    added
    enhancement
    api: storageIssues related to the Cloud Storage API.
    on Jun 6, 2015
  2. stephenplusplus commented on Sep 16, 2015

    @stephenplusplus
    stephenplusplus
    on Sep 16, 2015
    Contributor
    More actions

    @jgeewax @stellanhaglund will this solution work?

    • Docs: https://cloud.google.com/storage/docs/access-control?hl=en#signing-resumable
    • Issue: Authorization: Bearer your_auth_token (how to get auth_token) #818
    • Solution: Authorization: Bearer your_auth_token (how to get auth_token) #818 (comment)
      (this can be simplified with https://googlecloudplatform.github.io/gcloud-node/#/docs/v0.21.0/storage/file?method=createResumableUpload)
  3. stephenplusplus commented on Sep 16, 2015

    @stephenplusplus
    stephenplusplus
    on Sep 16, 2015
    Contributor
    More actions

    I made a couple of examples here showing two different ways to handle uploads. https://github.com/stephenplusplus/gcloud-upload-example

  4. stellanhaglund commented on Sep 17, 2015

    @stellanhaglund
    stellanhaglund
    on Sep 17, 2015
    More actions

    Thanks alot!!

    I just added that but now I'm trying to download a file using

    app.get('/file/:imageId', function(req, res){

    var remoteFile = bucket.file(req.params.imageId);
    var localFilename = 'uploads/' + req.params.imageId;

    var src = remoteFile.createReadStream()

    src
    .on('error', function(err) {})
    .on('response', function(response) {
    // Server connected and responded with the specified status and headers.
    })
    .on('end', function() {
    // The file is fully downloaded.
    })
    // .pipe(fs.createWriteStream(localFilename));

    res.attachment(localFilename);
    src.pipe(res);

    })

    but for larger files I just get about 1.2 mb downloaded..

    2015-09-17 1:27 GMT+02:00 Stephen Sawchuk [email protected]:

    I made a couple of examples here showing two different ways to handle
    uploads. https://github.com/stephenplusplus/gcloud-upload-example

    —
    Reply to this email directly or view it on GitHub
    #641 (comment)
    .

  5. stephenplusplus commented on Sep 17, 2015

    @stephenplusplus
    stephenplusplus
    on Sep 17, 2015
    Contributor
    More actions

    Which version of gcloud are you running?

  6. stellanhaglund commented on Sep 17, 2015

    @stellanhaglund
    stellanhaglund
    on Sep 17, 2015
    More actions
    "gcloud": "^0.21.0",
    

    2015-09-17 15:28 GMT+02:00 Stephen Sawchuk [email protected]:

    Which version of gcloud are you running?

    —
    Reply to this email directly or view it on GitHub
    #641 (comment)
    .

  7. stephenplusplus commented on Sep 17, 2015

    @stephenplusplus
    stephenplusplus
    on Sep 17, 2015
    Contributor
    More actions

    Hmm, I haven't been able to reproduce. How large are the files you're having trouble with? I've tried with a 10MB file without issues.

    I added onto the example with some options of how to download files: https://github.com/stephenplusplus/gcloud-upload-example/blob/1d6cbecb31aa2dcd98d1c8177e6c474b80b5d1f5/server.js#L89

  8. stellanhaglund commented on Sep 17, 2015

    @stellanhaglund
    stellanhaglund
    on Sep 17, 2015
    More actions

    about 300mb, and the files will probably be up to some gb's

    2015-09-17 16:16 GMT+02:00 Stephen Sawchuk [email protected]:

    Hmm, I haven't been able to reproduce. How large are the files you're
    having trouble with? I've tried with a 10MB file without issues.

    I added onto the example with some options of how to download files:
    https://github.com/stephenplusplus/gcloud-upload-example/blob/1d6cbecb31aa2dcd98d1c8177e6c474b80b5d1f5/server.js#L89

    —
    Reply to this email directly or view it on GitHub
    #641 (comment)
    .

  9. stephenplusplus commented on Sep 17, 2015

    @stephenplusplus
    stephenplusplus
    on Sep 17, 2015
    Contributor
    More actions

    Would you mind opening a new issue about this? Also, please test that it still doesn't work isolated from express, e.g.:

    remoteFile.createReadStream().pipe(fs.createWriteStream('./backup-file'))
  10. stephenplusplus commented on Nov 23, 2015

    @stephenplusplus
    stephenplusplus
    on Nov 23, 2015
    Contributor
    More actions

    I think we've got this one covered with file#createResumableUpload().

    Related, I just stumbled upon this project over the weekend: https://github.com/makeomatic/ms-files-gce

    If there's more we can do, let me know!

  11. stephenplusplus
    closed this as completedon Nov 23, 2015
  12. JustinBeckwith
    assigned
    stephenplusplus
    on Feb 1, 2021
  13. sofisl
    added 2 commits that reference this issue on Oct 11, 2022

    chore(deps): update dependency gts to v3 (#641)

    1a2fb92

    chore(deps): update dependency gts to v3 (#641)

    9540867
  14. 18 remaining items

  15. sofisl
    added a commit that references this issue on Feb 5, 2026

    chore: remove duplicate mocha config (#641)

    1cb3429
  16. GautamSharda
    added a commit that references this issue on Feb 5, 2026

    build: update auto approve to v2, remove release autoapproving (#1432) (

    d37d1bb
  17. sofisl
    added a commit that references this issue on Feb 17, 2026

    chore: remove duplicate mocha config (#641)

    3daed0b
  18. GautamSharda
    added a commit that references this issue on Feb 23, 2026

    build: update auto approve to v2, remove release autoapproving (#1432) (

    d2de71b
  19. sofisl
    added a commit that references this issue on Feb 25, 2026

    chore(deps): update dependency tmp to ^0.1.0 (#641)

    ba8dd64
  20. GautamSharda
    added a commit that references this issue on Feb 26, 2026

    build: update auto approve to v2, remove release autoapproving (#1432) (

    c9da659
  21. sofisl
    added a commit that references this issue on Feb 26, 2026

    chore(deps): update dependency @types/async to v3 (#641)

    0e037ce
  22. GautamSharda
    added a commit that references this issue on Mar 12, 2026

    build(node): add KOKORO_BUILD_ARTIFACTS_SUBDIR to env (#641)

    79caed9
  23. sofisl
    added 2 commits that reference this issue on Mar 17, 2026

    fix: release uuid rollback (#641)

    66aa9d2

    feat: release 6.2.0 (#641)

    547c34f
  24. thiyaguk09
    added a commit that references this issue on Mar 18, 2026

    chore(deps): update dependency tmp to ^0.1.0 (googleapis#641)

    645ed02
  25. GautamSharda
    added 2 commits that reference this issue on Mar 23, 2026

    fix: improve typescript types for Table class (#641)

    b0a2cd0

    fix: improve typescript types for Table class (#641)

    48e659b
  26. shivanee-p
    added a commit that references this issue on Mar 27, 2026

    fix: improve typescript types for Table class (#641)

    566e5a6
  27. thiyaguk09
    added a commit that references this issue on May 5, 2026

    fix: improve typescript types for Table class (googleapis#641)

    f6c1687
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @stephenplusplus
    stephenplusplus

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

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.