public sealed class RequestTemplate
Represents the request template to be signed.
Namespace
Google.Cloud.Storage.V1Assembly
Google.Cloud.Storage.V1.dll
Remarks
When either of the headers collections are specified, there are certain headers which will be included in the signed URL's signature, and therefore must be included in requests made with the created URL. These are the Content-MD5 and Content-Type content headers as well as any content or request header with a name starting with "x-goog-".
If the headers collections are null or empty, no headers are included in the signed URL's signature, so any requests made with the created URL must not contain Content-MD5, Content-Type, or any header starting with "x-goog-".
Note that when GET is specified as the HttpMethod (or it is null, in which case GET is used), both GET and HEAD requests can be made with the created signed URL.
Properties
Bucket
public string Bucket { get; }
The name of the bucket. This will never be null.
Property Value | |
---|---|
Type | Description |
String |
ContentHeaders
public IReadOnlyDictionary<string, IReadOnlyCollection<string>> ContentHeaders { get; }
The headers for the content which will be included with the request. This will never be null. If null is specified in WithContentHeaders(IEnumerable<KeyValuePair<String, IEnumerable<String>>>) then an empty dictionary will be used.
Property Value | |
---|---|
Type | Description |
IReadOnlyDictionary<String, IReadOnlyCollection<String>> |
When using V2, from all the headers supplied in ContentHeaders, only the ones starting with "x-goog-", the Content-MD5 and the Content-Type headers will be included in the signed URL's signature and therefor must be included in requests made with the created URL. All other headers supplied in ContentHeaders will be ignored when creating the signed URL so they shouldn't be included in requests made with the created URL.
When using V4 all headers supplied in ContentHeaders will be included in the signed URL's signature and therefor must be included in requests made with the created URL.
HttpMethod
public HttpMethod HttpMethod { get; }
The HTTP request method for which the signed URL is allowed to be used. This will never be null. If null is specified in WithHttpMethod(HttpMethod) then this value will be set to Get. Will default to Get.
Property Value | |
---|---|
Type | Description |
HttpMethod |
Note that when GET is specified as the HttpMethod, both GET and HEAD requests can be made with the created signed URL.
ObjectName
public string ObjectName { get; }
The name of the object within the bucket. May be null, in which case the signed URL will refer to the bucket instead of an object.
Property Value | |
---|---|
Type | Description |
String |
QueryParameters
public IReadOnlyDictionary<string, IReadOnlyCollection<string>> QueryParameters { get; }
The query parameters which will be included with the request. This will never be null. If null is specified in WithQueryParameters(IEnumerable<KeyValuePair<String, IEnumerable<String>>>) then an empty dictionary will be used.
Property Value | |
---|---|
Type | Description |
IReadOnlyDictionary<String, IReadOnlyCollection<String>> |
When using V2 custom query parameters are not supported by the signing process and Sign(UrlSigner.RequestTemplate, UrlSigner.Options) and SignAsync(UrlSigner.RequestTemplate, UrlSigner.Options, CancellationToken) will throw ArgumentException if QueryParameters is not an empty dictionary, that is, if one or more custom query parameters have been specified.
RequestHeaders
public IReadOnlyDictionary<string, IReadOnlyCollection<string>> RequestHeaders { get; }
The headers which will be included with the request. This will never be null. If null is specified in WithRequestHeaders(IEnumerable<KeyValuePair<String, IEnumerable<String>>>) then an empty dictionary will be used.
Property Value | |
---|---|
Type | Description |
IReadOnlyDictionary<String, IReadOnlyCollection<String>> |
When using V2, from all the headers supplied in RequestHeaders, only the ones starting with "x-goog-" will be included in the signed URL's signature and therefor must be included in requests made with the created URL. All other headers supplied in RequestHeaders will be ignored when creating the signed URL so they shouldn't be included in requests made with the created URL.
When using V4 all headers supplied in RequestHeaders will be included in the signed URL's signature and therefor must be included in requests made with the created URL.Note that if the entity is encrypted with customer-supplied encryption keys (see https://cloud.google.com/storage/docs/encryption for more information), the x-goog-encryption-algorithm, x-goog-encryption-key, and x-goog-encryption-key-sha256 headers will be required when making the request. However, only the x-goog-encryption-algorithm header is included in the signature for the signed URL. So the RequestHeaders specified only need to have the x-goog-encryption-algorithm header.
Methods
FromBucket(String)
public static UrlSigner.RequestTemplate FromBucket(string bucket)
Creates a new request template to sign from the given bucket name.
Parameter | |
---|---|
Name | Description |
bucket | String The name of the bucket for which the signed URL will be created. Must not be null. |
Returns | |
---|---|
Type | Description |
UrlSigner.RequestTemplate | A new request template. |
WithBucket(String)
public UrlSigner.RequestTemplate WithBucket(string bucket)
Returns a new request template with all the same settings as this one except for the bucket name.
Parameter | |
---|---|
Name | Description |
bucket | String The new bucket name. Must not be null. |
Returns | |
---|---|
Type | Description |
UrlSigner.RequestTemplate | A new request template. |
WithContentHeaders(IEnumerable<KeyValuePair<String, IEnumerable<String>>>)
public UrlSigner.RequestTemplate WithContentHeaders(IEnumerable<KeyValuePair<string, IEnumerable<string>>> contentHeaders)
Returns a new request template with all the same settings as this one except for the content headers.
Parameter | |
---|---|
Name | Description |
contentHeaders | IEnumerable<KeyValuePair<String, IEnumerable<String>>> The new content headers. May be null, in which case an empty collection will be used. |
Returns | |
---|---|
Type | Description |
UrlSigner.RequestTemplate | A new request template. |
WithHttpMethod(HttpMethod)
public UrlSigner.RequestTemplate WithHttpMethod(HttpMethod method)
Returns a new request template with all the same settings as this one except for the HTTP method.
Parameter | |
---|---|
Name | Description |
method | HttpMethod The new HTTP method. May be null, in which case Get will be used. |
Returns | |
---|---|
Type | Description |
UrlSigner.RequestTemplate | A new request template. |
WithHttpRequestMessage(HttpRequestMessage)
public UrlSigner.RequestTemplate WithHttpRequestMessage(HttpRequestMessage requestMessage)
Returns a new request template with all the same settings as this one
except for all the information that can be obtained from requestMessage
,
that is the HTTP method, the request headers and the content headers.
Parameter | |
---|---|
Name | Description |
requestMessage | HttpRequestMessage The new request message. May be null, in which case the default values for all the affected properties will be used.. |
Returns | |
---|---|
Type | Description |
UrlSigner.RequestTemplate | A new request template. |
WithObjectName(String)
public UrlSigner.RequestTemplate WithObjectName(string objectName)
Returns a new request template with all the same settings as this one except for the object name.
Parameter | |
---|---|
Name | Description |
objectName | String The new object name. May be null, in which case the signed URL will refer to the bucket instead of an object. |
Returns | |
---|---|
Type | Description |
UrlSigner.RequestTemplate | A new request template. |
WithQueryParameters(IEnumerable<KeyValuePair<String, IEnumerable<String>>>)
public UrlSigner.RequestTemplate WithQueryParameters(IEnumerable<KeyValuePair<string, IEnumerable<string>>> queryParameters)
Returns a new request template with all the same settings as this one except for the query parameters.
Parameter | |
---|---|
Name | Description |
queryParameters | IEnumerable<KeyValuePair<String, IEnumerable<String>>> The new query parameters. May be null, in which case an empty collection will be used. |
Returns | |
---|---|
Type | Description |
UrlSigner.RequestTemplate | A new request template. |
WithRequestHeaders(IEnumerable<KeyValuePair<String, IEnumerable<String>>>)
public UrlSigner.RequestTemplate WithRequestHeaders(IEnumerable<KeyValuePair<string, IEnumerable<string>>> requestHeaders)
Returns a new request template with all the same settings as this one except for the request headers.
Parameter | |
---|---|
Name | Description |
requestHeaders | IEnumerable<KeyValuePair<String, IEnumerable<String>>> The new request headers. May be null, in which case an empty collection will be used. |
Returns | |
---|---|
Type | Description |
UrlSigner.RequestTemplate | A new request template. |