5.0.0 (latest) 4.16.0 4.15.0 4.14.0 4.13.0 4.11.0 4.10.0 4.9.0 4.8.0 4.7.0 4.6.0 4.5.0 4.4.0 4.3.0 4.2.0 4.1.0 4.0.0 3.7.0 3.6.0 3.5.0 3.4.0

    public sealed class UrlSigner.RequestTemplate

Reference documentation and code samples for the Google Cloud Storage v1 API class UrlSigner.RequestTemplate.

Represents the request template to be signed.

## Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) \> UrlSigner.RequestTemplate

## Inherited Members

[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Namespace

[Google.Cloud.Storage.V1](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1)

## Assembly

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](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.RequestTemplate#Google_Cloud_Storage_V1_UrlSigner_RequestTemplate_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** |
| `https://learn.microsoft.com/dotnet/api/system.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\>\>\>)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.RequestTemplate#Google_Cloud_Storage_V1_UrlSigner_RequestTemplate_WithContentHeaders_System_Collections_Generic_IEnumerable_System_Collections_Generic_KeyValuePair_System_String_System_Collections_Generic_IEnumerable_System_String____)
then an empty dictionary will be used.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| ``https://learn.microsoft.com/dotnet/api/system.collections.generic.ireadonlydictionary-2https://learn.microsoft.com/dotnet/api/system.stringSystem.Collections.Generic.IReadOnlyCollection`1https://learn.microsoft.com/dotnet/api/system.string`` |   |

**Remarks**
When using [V2](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.SigningVersion#Google_Cloud_Storage_V1_SigningVersion_V2), from all the headers supplied in [ContentHeaders](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.RequestTemplate#Google_Cloud_Storage_V1_UrlSigner_RequestTemplate_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](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.RequestTemplate#Google_Cloud_Storage_V1_UrlSigner_RequestTemplate_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](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.SigningVersion#Google_Cloud_Storage_V1_SigningVersion_V4) all headers supplied in [ContentHeaders](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.RequestTemplate#Google_Cloud_Storage_V1_UrlSigner_RequestTemplate_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)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.RequestTemplate#Google_Cloud_Storage_V1_UrlSigner_RequestTemplate_WithHttpMethod_System_Net_Http_HttpMethod_)
then this value will be set to [Get](https://learn.microsoft.com/dotnet/api/system.net.http.httpmethod.get).
Will default to [Get](https://learn.microsoft.com/dotnet/api/system.net.http.httpmethod.get).

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.net.http.httpmethod` |   |

**Remarks**
Note that when GET is specified as the [HttpMethod](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.RequestTemplate#Google_Cloud_Storage_V1_UrlSigner_RequestTemplate_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** |
| `https://learn.microsoft.com/dotnet/api/system.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\>\>\>)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.RequestTemplate#Google_Cloud_Storage_V1_UrlSigner_RequestTemplate_WithQueryParameters_System_Collections_Generic_IEnumerable_System_Collections_Generic_KeyValuePair_System_String_System_Collections_Generic_IEnumerable_System_String____)
then an empty dictionary will be used.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| ``https://learn.microsoft.com/dotnet/api/system.collections.generic.ireadonlydictionary-2https://learn.microsoft.com/dotnet/api/system.stringSystem.Collections.Generic.IReadOnlyCollection`1https://learn.microsoft.com/dotnet/api/system.string`` |   |

**Remarks** When using [V2](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.SigningVersion#Google_Cloud_Storage_V1_SigningVersion_V2) custom query parameters are not supported by the signing process
and [Sign(RequestTemplate, Options)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner#Google_Cloud_Storage_V1_UrlSigner_Sign_Google_Cloud_Storage_V1_UrlSigner_RequestTemplate_Google_Cloud_Storage_V1_UrlSigner_Options_) and
[SignAsync(RequestTemplate, Options, CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner#Google_Cloud_Storage_V1_UrlSigner_SignAsync_Google_Cloud_Storage_V1_UrlSigner_RequestTemplate_Google_Cloud_Storage_V1_UrlSigner_Options_System_Threading_CancellationToken_)
will throw [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception) if [QueryParameters](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.RequestTemplate#Google_Cloud_Storage_V1_UrlSigner_RequestTemplate_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\>\>\>)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.RequestTemplate#Google_Cloud_Storage_V1_UrlSigner_RequestTemplate_WithRequestHeaders_System_Collections_Generic_IEnumerable_System_Collections_Generic_KeyValuePair_System_String_System_Collections_Generic_IEnumerable_System_String____)
then an empty dictionary will be used.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| ``https://learn.microsoft.com/dotnet/api/system.collections.generic.ireadonlydictionary-2https://learn.microsoft.com/dotnet/api/system.stringSystem.Collections.Generic.IReadOnlyCollection`1https://learn.microsoft.com/dotnet/api/system.string`` |   |

**Remarks**
When using [V2](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.SigningVersion#Google_Cloud_Storage_V1_SigningVersion_V2), from all the headers supplied in [RequestHeaders](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.RequestTemplate#Google_Cloud_Storage_V1_UrlSigner_RequestTemplate_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](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.RequestTemplate#Google_Cloud_Storage_V1_UrlSigner_RequestTemplate_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](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.SigningVersion#Google_Cloud_Storage_V1_SigningVersion_V4) all headers supplied in [RequestHeaders](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.RequestTemplate#Google_Cloud_Storage_V1_UrlSigner_RequestTemplate_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](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.RequestTemplate#Google_Cloud_Storage_V1_UrlSigner_RequestTemplate_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` | `https://learn.microsoft.com/dotnet/api/system.string` The name of the bucket for which the signed URL will be created. Must not be null. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSignerhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.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` | `https://learn.microsoft.com/dotnet/api/system.string` The new bucket name. Must not be null. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSignerhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.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` | ``https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1System.Collections.Generic.KeyValuePair`2https://learn.microsoft.com/dotnet/api/system.stringhttps://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1https://learn.microsoft.com/dotnet/api/system.string`` The new content headers. May be null, in which case an empty collection will be used. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSignerhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.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` | `https://learn.microsoft.com/dotnet/api/system.net.http.httpmethod` The new HTTP method. May be null, in which case [Get](https://learn.microsoft.com/dotnet/api/system.net.http.httpmethod.get) will be used. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSignerhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.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` | `https://learn.microsoft.com/dotnet/api/system.net.http.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** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSignerhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.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` | `https://learn.microsoft.com/dotnet/api/system.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** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSignerhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.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` | ``https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1System.Collections.Generic.KeyValuePair`2https://learn.microsoft.com/dotnet/api/system.stringhttps://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1https://learn.microsoft.com/dotnet/api/system.string`` The new query parameters. May be null, in which case an empty collection will be used. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSignerhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.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` | ``https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1System.Collections.Generic.KeyValuePair`2https://learn.microsoft.com/dotnet/api/system.stringhttps://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1https://learn.microsoft.com/dotnet/api/system.string`` The new request headers. May be null, in which case an empty collection will be used. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSignerhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.RequestTemplate` | A new request template. |