Skip to content

getSignedUrl called synchronously ? #251

Description

@andreij

I have a simple functions that returns a signed url :

  var   options = config.gs
    ,   expires = Math.round(Date.now() / 1000) + (60 * 60 * 24 * 14)
    ,   bucket  = project.storage.bucket({bucketName: config.gs.bucket, credentials: config.gs })

  options.action  = 'read'
  options.expires =  expires// 2 weeks.
  options.resource= url

  signed_url = bucket.getSignedUrl(options, function(err, url_signed) {})
  return signed_url

I cannot understand how to call it synchronously.

The signed_url is always undefined but inside the callback the url_signed is correctly set.

So if I log the signed_url and the url_signed i get:

signed_url: undefined
url_signed: http://.......

Activity

  1. stephenplusplus commented on Oct 9, 2014

    @stephenplusplus
    Contributor

    I think this is the fault of our documentation. http://googlecloudplatform.github.io/gcloud-node/#/docs/v0.8.0/storage?method=getSignedUrl shows that it's returned synchronously, but that's actually not the case. You have to use it asynchronously as you've discovered.

    Internally, a connection is required in order to generate a signed url, which is why it must be async. Sorry for the confusion and thanks for bringing attention to this-- I'll go and update the example.

  2. stephenplusplus commented on Oct 9, 2014

    @stephenplusplus
    Contributor

    Fixed here: 5def8e7

  3. added
    api: datastoreIssues related to the Datastore API.
    api: storageIssues related to the Cloud Storage API.
    type: questionRequest for information or clarification. Not an issue.
    and removed
    api: datastoreIssues related to the Datastore API.
    on Feb 2, 2015
  4. added this to the Storage Stable milestone on Feb 2, 2015
  5. 13 remaining items

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

Metadata

Metadata

Labels

api: storageIssues related to the Cloud Storage API.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions