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.Options

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

Options for the UrlSigner.
Options can be duration or expiration based regarding the validity of the signed URL.

## Inheritance

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

## 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

## Properties

### BucketBoundHostname

    public string BucketBoundHostname { get; }

A bucket bound host to use for generating the signed URL.
If [UrlStyle](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.Options#Google_Cloud_Storage_V1_UrlSigner_Options_UrlStyle) is [BucketBoundHostname](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.UrlStyle#Google_Cloud_Storage_V1_UrlSigner_UrlStyle_BucketBoundHostname) this won't be null.
It will be null otherwise.
Use [WithBucketBoundHostname(string)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.Options#Google_Cloud_Storage_V1_UrlSigner_Options_WithBucketBoundHostname_System_String_) to set.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://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) bucket bound host names are not supported
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 [BucketBoundHostname](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.Options#Google_Cloud_Storage_V1_UrlSigner_Options_BucketBoundHostname) is not null.

### Duration

    public TimeSpan? Duration { get; }

The length of time for which the signed URL should remain usable,
counting from the moment the signed URL is created.
Exactly one of [Duration](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.Options#Google_Cloud_Storage_V1_UrlSigner_Options_Duration) and [Expiration](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.Options#Google_Cloud_Storage_V1_UrlSigner_Options_Expiration)
will be set.

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

### Expiration

    public DateTimeOffset? Expiration { get; }

The point in time after which the signed URL will be invalid.
Exactly one of [Duration](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.Options#Google_Cloud_Storage_V1_UrlSigner_Options_Duration) and [Expiration](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.Options#Google_Cloud_Storage_V1_UrlSigner_Options_Expiration)
will be set.

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

### Host

    public string Host { get; }

The host to use for generating the signed URL.
This will never be null. If null is specified in [WithHost(string)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.Options#Google_Cloud_Storage_V1_UrlSigner_Options_WithHost_System_String_)
then the appropriate default value will be used.
Will be ignored if [UrlStyle](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.Options#Google_Cloud_Storage_V1_UrlSigner_Options_UrlStyle) is set to [BucketBoundHostname](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.UrlStyle#Google_Cloud_Storage_V1_UrlSigner_UrlStyle_BucketBoundHostname).

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

### Port

    public int? Port { get; }

The port for the signed URL. The port is not included on the signature itself, only on the
resulting signed URL. Defaults to null.
Will be ignored if [UrlStyle](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.Options#Google_Cloud_Storage_V1_UrlSigner_Options_UrlStyle) is set to [BucketBoundHostname](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.UrlStyle#Google_Cloud_Storage_V1_UrlSigner_UrlStyle_BucketBoundHostname).

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

### Scheme

    public string Scheme { get; }

The Scheme to use for the request. Only http or https supported.
This will never be null. If null is specified in [WithScheme(string)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.Options#Google_Cloud_Storage_V1_UrlSigner_Options_WithScheme_System_String_)
an appropriate default value will be used.

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

### SigningVersion

    public SigningVersion SigningVersion { get; }

The signing version to use for generating the signed URL.
This will default to [Default](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.SigningVersion#Google_Cloud_Storage_V1_SigningVersion_Default)
which is currently the same as [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).

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.SigningVersion` |   |

### UrlStyle

    public UrlSigner.UrlStyle UrlStyle { get; }

The style of signed URL to generate.
Defaults to [PathStyle](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.UrlStyle#Google_Cloud_Storage_V1_UrlSigner_UrlStyle_PathStyle).

| **Property Value** ||
|---|---|
| **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.UrlStyle` |   |

**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) only [PathStyle](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.UrlStyle#Google_Cloud_Storage_V1_UrlSigner_UrlStyle_PathStyle) and [VirtualHostedStyle](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.UrlStyle#Google_Cloud_Storage_V1_UrlSigner_UrlStyle_VirtualHostedStyle)
are supported 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 [UrlStyle](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.Options#Google_Cloud_Storage_V1_UrlSigner_Options_UrlStyle) is other than one of these two values.

## Methods

### FromDuration(TimeSpan)

    public static UrlSigner.Options FromDuration(TimeSpan duration)

Creates a new [UrlSigner.Options](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.Options) from the given duration.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `duration` | `https://learn.microsoft.com/dotnet/api/system.timespan` The duration to create these options with. |

| **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.Options` | A new options set. |

### FromExpiration(DateTimeOffset)

    public static UrlSigner.Options FromExpiration(DateTimeOffset expiration)

Creates a new [UrlSigner.Options](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.Options) from the given expiration.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `expiration` | `https://learn.microsoft.com/dotnet/api/system.datetimeoffset` The expiration to create these options with. |

| **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.Options` | A new options set. |

### WithBucketBoundHostname(string)

    public UrlSigner.Options WithBucketBoundHostname(string bucketBoundHostname)

Returns a new set of options with the same values as this one except for bucket bound domain
and the url style which will be set to [BucketBoundHostname](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.UrlStyle#Google_Cloud_Storage_V1_UrlSigner_UrlStyle_BucketBoundHostname).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `bucketBoundHostname` | `https://learn.microsoft.com/dotnet/api/system.string` The new bucket bound domain. |

| **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.Options` | A new set of options with the given bucket bound domain and the url style set to [BucketBoundHostname](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.UrlStyle#Google_Cloud_Storage_V1_UrlSigner_UrlStyle_BucketBoundHostname). |

### WithDuration(TimeSpan)

    public UrlSigner.Options WithDuration(TimeSpan duration)

Returns a new set of options with the same values as this one but duration based.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `duration` | `https://learn.microsoft.com/dotnet/api/system.timespan` The new duration. |

| **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.Options` | A new set of options with the given duration. |

### WithExpiration(DateTimeOffset)

    public UrlSigner.Options WithExpiration(DateTimeOffset expiration)

Returns a new set of options with the same values as this one but expiration based.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `expiration` | `https://learn.microsoft.com/dotnet/api/system.datetimeoffset` The new expiration. |

| **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.Options` | A new set of options with the given expiration. |

### WithHost(string)

    public UrlSigner.Options WithHost(string host)

Returns a new set of options with the same values as this one except for the host.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `host` | `https://learn.microsoft.com/dotnet/api/system.string` The new host. May be null in which case Google.Cloud.Storage.V1.UrlSigner.Options.DefaultStorageHost 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.Options` | A new set of options with the given host. |

### WithPort(int?)

    public UrlSigner.Options WithPort(int? port)

Returns a new set of options with the same values as this one except for the port.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `port` | `https://learn.microsoft.com/dotnet/api/system.int32` The new port. May 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.Options` | A new set of options with the given host. |

### WithScheme(string)

    public UrlSigner.Options WithScheme(string scheme)

Returns a new set of options with the same values as this one except for the scheme.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `scheme` | `https://learn.microsoft.com/dotnet/api/system.string` The new scheme. May be null in which case https 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.Options` | A new set of options with the given scheme. |

### WithSigningVersion(SigningVersion)

    public UrlSigner.Options WithSigningVersion(SigningVersion version)

Returns a new set of options with the same values as this one except for the signing version.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `version` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.SigningVersion` The new signing version. |

| **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.Options` | A set of options with the given signing version. |

### WithUrlStyle(UrlStyle)

    public UrlSigner.Options WithUrlStyle(UrlSigner.UrlStyle urlStyle)

Returns a new set of options with the same values as this one except for the
[UrlStyle](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.Options#Google_Cloud_Storage_V1_UrlSigner_Options_UrlStyle) value and [BucketBoundHostname](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.Options#Google_Cloud_Storage_V1_UrlSigner_Options_BucketBoundHostname) set to null.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `urlStyle` | `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.UrlStyle` The new url style. |

| **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.Options` | A new set ofoptions with the given url style. |

**Remarks** Use [WithBucketBoundHostname(string)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.Options#Google_Cloud_Storage_V1_UrlSigner_Options_WithBucketBoundHostname_System_String_) to set [BucketBoundHostname](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.UrlStyle#Google_Cloud_Storage_V1_UrlSigner_UrlStyle_BucketBoundHostname).