3

Using the gcloud Node library, how do I get the URL for a file within a Cloud Storage bucket?

Consider the following instantation of a file object:

let bucket = gcs.bucket(`aBucket`)
let cloudFile = bucket.file(`aFile`)

I would like to get the URL for downloading cloudFile.

aknuds1
  • 65,625
  • 67
  • 195
  • 317

2 Answers2

9

You can use a variety of request URIs, including storage.googleapis.com/<bucket>/<object>.

jarmod
  • 71,565
  • 16
  • 115
  • 122
1

If file is public, then you can use a corresponding method:

cloudFile.publicUrl()
Ivan Gusev
  • 252
  • 5
  • 10