Search code examples
node.jsgoogle-cloud-platformservice-accountsgsutil

GoogleCloud: With service account credentials, how to access all files under directory ? How to get SignedUrl for entire directory?


Google Cloud: I have stored some files under xyz folder which is under ABC bucket. We have created service account to access those files. I am able to create signed URL for each file with gsutil:

gsutil signurl -d 120s key.json gs://bucketname/folderNmae/index.html

Instead of creating signedURL for all files I want to access directly folder. Do we have any solution to do that?

Tried creating signedURL for folder but got error:

Please create/upload an object with that name before a creating signed URL to access it.


Solution

  • You can use the following command to achieve that functionality:

    gsutil signurl -d 120s key.json gs://bucketname/folderName/**
    

    This will create a SignedURL for each of the files inside your bucket.

    More information about using Wildcard Names in gsutil commands can be found in this link from the documentation.