Skip to content
This repository has been archived by the owner on Jun 24, 2024. It is now read-only.

Allow setting an origin #6

Closed
stephenplusplus opened this issue Feb 1, 2016 · 3 comments
Closed

Allow setting an origin #6

stephenplusplus opened this issue Feb 1, 2016 · 3 comments
Assignees
Labels
api: storage Issues related to the googleapis/gcs-resumable-upload API. 🚨 This issue needs some love. triage me I really want to be triaged.

Comments

@stephenplusplus
Copy link
Contributor

@janesconference - any interest in adding support for any options we're currently missing?

@cristiano-belloni
Copy link

Hi @stephenplusplus, you're right, I should have opened a PR, but I'm totally swamped right now. What I have is a POC that works simply setting

this.origin = cfg.origin

in the function Upload constructor

Then, in Upload.prototype.createURI, I do:

if (this.origin) {
    reqOpts.headers = {
      'Origin': this.origin
    }
  }

Then, from my server, I crudely instantiate:

createURI({
      authClient: file.bucket.storage.authClient,
      bucket: file.bucket.name,
      file: file.name,
      generation: file.generation,
      metadata: {},
      origin: origin
    }, function(err, url) {
      if (err) {
        cb(err, null)
        return
      }

      cb(null, {
        url: url,
        id: fileObj.id
      })
    })

where file is a valid file object created via bucket.file.

When a browser client calls my node API, I just get the client's origin with req.get('origin') (optionally checking it) and everything works.

I wish I had time to put it together in a nice PR, but for now I don't even have that one hour to dedicate to it :/

@stephenplusplus
Copy link
Contributor Author

No problem at all! Thanks for sending this.

@stephenplusplus
Copy link
Contributor Author

Released in 0.4.0: 8f96167

@google-cloud-label-sync google-cloud-label-sync bot added the api: storage Issues related to the googleapis/gcs-resumable-upload API. label Jan 31, 2020
@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Apr 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api: storage Issues related to the googleapis/gcs-resumable-upload API. 🚨 This issue needs some love. triage me I really want to be triaged.
Projects
None yet
Development

No branches or pull requests

3 participants