Package com.google.cloud.storage
Class Storage.SignUrlOption
java.lang.Object
com.google.cloud.storage.Storage.SignUrlOption
- All Implemented Interfaces:
Serializable
- Enclosing interface:
- Storage
Class for specifying signed URL options.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic Storage.SignUrlOption
httpMethod
(HttpMethod httpMethod) The HTTP method to be used with the signed URL.static Storage.SignUrlOption
signWith
(com.google.auth.ServiceAccountSigner signer) Provides a service account signer to sign the URL.static Storage.SignUrlOption
withBucketBoundHostname
(String bucketBoundHostname) Use a bucket-bound hostname, which replaces the storage.googleapis.com host with the name of a CNAME bucket, e.g.static Storage.SignUrlOption
withBucketBoundHostname
(String bucketBoundHostname, Storage.UriScheme uriScheme) Use a bucket-bound hostname, which replaces the storage.googleapis.com host with the name of a CNAME bucket, e.g.static Storage.SignUrlOption
Use it if signature should include the blob's content-type.static Storage.SignUrlOption
withExtHeaders
(Map<String, String> extHeaders) Use it if signature should include the blob's canonicalized extended headers.static Storage.SignUrlOption
withHostName
(String hostName) Use a different host name than the default host name 'storage.googleapis.com'.static Storage.SignUrlOption
withMd5()
Use it if signature should include the blob's md5.static Storage.SignUrlOption
Generates a path-style URL, which places the bucket name in the path portion of the URL instead of in the hostname, e.g 'https://storage.googleapis.com/mybucket/...'.static Storage.SignUrlOption
withQueryParams
(Map<String, String> queryParams) Use if the URL should contain additional query parameters.static Storage.SignUrlOption
Use if signature version should be V2.static Storage.SignUrlOption
Use if signature version should be V4.static Storage.SignUrlOption
Use a virtual hosted-style hostname, which adds the bucket into the host portion of the URI rather than the path, e.g.
-
Method Details
-
httpMethod
The HTTP method to be used with the signed URL. If this method is not called, defaults to GET. -
withContentType
Use it if signature should include the blob's content-type. When used, users of the signed URL should include the blob's content-type with their request. If using this URL from a browser, you must include a content type that matches what the browser will send. -
withMd5
Use it if signature should include the blob's md5. When used, users of the signed URL should include the blob's md5 with their request. -
withExtHeaders
@TransportCompatibility(HTTP) public static Storage.SignUrlOption withExtHeaders(Map<String, String> extHeaders) Use it if signature should include the blob's canonicalized extended headers. When used, users of the signed URL should include the canonicalized extended headers with their request.- See Also:
-
withV2Signature
Use if signature version should be V2. This is the default if neither this orwithV4Signature()
is called. -
withV4Signature
Use if signature version should be V4. Note that V4 Signed URLs can't have an expiration longer than 7 days. V2 will be the default if neither this orwithV2Signature()
is called. -
signWith
@TransportCompatibility(HTTP) public static Storage.SignUrlOption signWith(com.google.auth.ServiceAccountSigner signer) Provides a service account signer to sign the URL. If not provided an attempt is made to get it from the environment.- See Also:
-
withHostName
Use a different host name than the default host name 'storage.googleapis.com'. This option is particularly useful for developers to point requests to an alternate endpoint (e.g. a staging environment or sending requests through VPC). If using this with thewithVirtualHostedStyle()
method, you should omit the bucket name from the hostname, as it automatically gets prepended to the hostname for virtual hosted-style URLs. -
withVirtualHostedStyle
Use a virtual hosted-style hostname, which adds the bucket into the host portion of the URI rather than the path, e.g. 'https://mybucket.storage.googleapis.com/...'. The bucket name is obtained from the resource passed in. For V4 signing, this also sets the "host" header in the canonicalized extension headers to the virtual hosted-style host, unless that header is supplied via thewithExtHeaders()
method.- See Also:
-
withPathStyle
Generates a path-style URL, which places the bucket name in the path portion of the URL instead of in the hostname, e.g 'https://storage.googleapis.com/mybucket/...'. This cannot be used alongsidewithVirtualHostedStyle()
. Virtual hosted-style URLs, which can be used via thewithVirtualHostedStyle()
method, should generally be preferred instead of path-style URLs.- See Also:
-
withBucketBoundHostname
@TransportCompatibility(HTTP) public static Storage.SignUrlOption withBucketBoundHostname(String bucketBoundHostname) Use a bucket-bound hostname, which replaces the storage.googleapis.com host with the name of a CNAME bucket, e.g. a bucket named 'gcs-subdomain.my.domain.tld', or a Google Cloud Load Balancer which routes to a bucket you own, e.g. 'my-load-balancer-domain.tld'. This cannot be used alongsidewithVirtualHostedStyle()
orwithPathStyle()
. This method signature uses HTTP for the URI scheme, and is equivalent to callingwithBucketBoundHostname("...", UriScheme.HTTP).
- See Also:
-
withBucketBoundHostname
@TransportCompatibility(HTTP) public static Storage.SignUrlOption withBucketBoundHostname(String bucketBoundHostname, Storage.UriScheme uriScheme) Use a bucket-bound hostname, which replaces the storage.googleapis.com host with the name of a CNAME bucket, e.g. a bucket named 'gcs-subdomain.my.domain.tld', or a Google Cloud Load Balancer which routes to a bucket you own, e.g. 'my-load-balancer-domain.tld'. Note that this cannot be used alongsidewithVirtualHostedStyle()
orwithPathStyle()
. The bucket name itself should not include the URI scheme (http or https), so it is specified via a local enum.- See Also:
-
withQueryParams
@TransportCompatibility(HTTP) public static Storage.SignUrlOption withQueryParams(Map<String, String> queryParams) Use if the URL should contain additional query parameters.Warning: For V2 Signed URLs, it is possible for query parameters to be altered after the URL has been signed, as the parameters are not used to compute the signature. The V4 signing method should be preferred when supplying additional query parameters, as the parameters cannot be added, removed, or otherwise altered after a V4 signature is generated.
- See Also:
-