public static class Storage.SignUrlOption implements Serializable
Class for specifying signed URL options.
Inheritance
Object >
Storage.SignUrlOption
Static Methods
httpMethod(HttpMethod httpMethod)
public static Storage.SignUrlOption httpMethod(HttpMethod httpMethod)
The HTTP method to be used with the signed URL. If this method is not called, defaults to
GET.
Parameter
Returns
signWith(ServiceAccountSigner signer)
public static Storage.SignUrlOption signWith(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: Service Accounts
Parameter
Name |
Description |
signer |
com.google.auth.ServiceAccountSigner
|
Returns
withBucketBoundHostname(String bucketBoundHostname)
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 alongside withVirtualHostedStyle()
or withPathStyle()
. This method
signature uses HTTP for the URI scheme, and is equivalent to calling
withBucketBoundHostname("...", UriScheme.HTTP).
See Also: GCLB Redirects, CNAME Redirects
Parameter
Name |
Description |
bucketBoundHostname |
String
|
Returns
withBucketBoundHostname(String bucketBoundHostname, Storage.UriScheme uriScheme)
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 alongside withVirtualHostedStyle()
or withPathStyle()
. The
bucket name itself should not include the URI scheme (http or https), so it is specified via
a local enum.
See Also: GCLB Redirects, CNAME Redirects
Parameters
Returns
withContentType()
public static Storage.SignUrlOption 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.
Returns
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: Request Headers
Parameter
Returns
withHostName(String hostName)
public static Storage.SignUrlOption withHostName(String hostName)
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 the
withVirtualHostedStyle()
method, you should omit the bucket name from the hostname, as it
automatically gets prepended to the hostname for virtual hosted-style URLs.
Parameter
Name |
Description |
hostName |
String
|
Returns
withMd5()
public static Storage.SignUrlOption 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.
Returns
withPathStyle()
public static Storage.SignUrlOption 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 alongside withVirtualHostedStyle()
. Virtual hosted-style URLs, which can be used
via the withVirtualHostedStyle()
method, should generally be preferred instead of
path-style URLs.
See Also: Request Endpoints
Returns
withQueryParams(Map<String,String> queryParams)
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: V2 Signing Process, Canonical Requests
Parameter
Returns
withV2Signature()
public static Storage.SignUrlOption withV2Signature()
Use if signature version should be V2. This is the default if neither this or
withV4Signature()
is called.
Returns
withV4Signature()
public static Storage.SignUrlOption 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 or withV2Signature()
is
called.
Returns
withVirtualHostedStyle()
public static Storage.SignUrlOption 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 the withExtHeaders()
method.
See Also: Request Endpoints
Returns