signurl - Create a signed url
gsutil signurl [-c <content_type>] [-d <duration>] [-m <http_method>] \ [-p <password>] [-r <region>] keystore-file url...
The signurl command will generate a signed URL that embeds authentication data so the URL can be used by someone who does not have a Google account. Please see the Signed URLs documentation for background about signed URLs.
Multiple gs:// urls may be provided and may contain wildcards. A signed url will be produced for each provided url, authorized for the specified HTTP method and valid for the given duration.
Note: Unlike the gsutil ls command, the signurl command does not support operations on sub-directories. For example, if you run the command:
gsutil signurl <private-key-file> gs://some-bucket/some-object/
The signurl command uses the private key for a service account (the '<private-key-file>' argument) to generate the cryptographic signature for the generated URL. The private key file must be in PKCS12 or JSON format. If the private key is encrypted the signed url command will prompt for the passphrase used to protect the private key file (default 'notasecret'). For more information regarding generating a private key for use with the signurl command please see the Authentication documentation.
gsutil will look up information about the object "some-object/" (with a trailing slash) inside bucket "some-bucket", as opposed to operating on objects nested under gs://some-bucket/some-object. Unless you actually have an object with that name, the operation will fail.
|-m||Specifies the HTTP method to be authorized for use with the signed url, default is GET. You may also specify RESUMABLE to create a signed resumable upload start URL. When using a signed URL to start a resumable upload session, you will need to specify the 'x-goog-resumable:start' header in the request or else signature validation will fail.|
Specifies the duration that the signed url should be valid for, default duration is 1 hour.
Times may be specified with no suffix (default hours), or with s = seconds, m = minutes, h = hours, d = days.
This option may be specified multiple times, in which case the duration the link remains valid is the sum of all the duration options.
The max duration allowed is 7d.
|-c||Specifies the content type for which the signed url is valid for.|
|-p||Specify the keystore password instead of prompting.|
Specifies the region in which the resources for which you are creating signed URLs are stored.
Default value is 'auto' which will cause gsutil to fetch the region for the resource. When auto-detecting the region, the current gsutil user's credentials, not the credentials from the private-key-file, are used to fetch the bucket's metadata.
This option must be specified and not 'auto' when generating a signed URL to create a bucket.
Create a signed url for downloading an object valid for 10 minutes:
gsutil signurl -d 10m <private-key-file> gs://<bucket>/<object>
Create a signed url, valid for one hour, for uploading a plain text file via HTTP PUT:
gsutil signurl -m PUT -d 1h -c text/plain <private-key-file> \ gs://<bucket>/<obj>
To construct a signed URL that allows anyone in possession of the URL to PUT to the specified bucket for one day, creating an object of Content-Type image/jpg, run:
gsutil signurl -m PUT -d 1d -c image/jpg <private-key-file> \ gs://<bucket>/<obj>
To construct a signed URL that allows anyone in possession of the URL to POST a resumable upload to the specified bucket for one day, creating an object of Content-Type image/jpg, run:
gsutil signurl -m RESUMABLE -d 1d -c image/jpg <private-key-file> \ gs://bucket/<obj>