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

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

Represents an unsigned post policy. It needs to be signed with [Sign(PostPolicy, 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_PostPolicy_Google_Cloud_Storage_V1_UrlSigner_Options_)
before it is used to enforced policies when posting objects via form.

## Inheritance

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

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

### Bucket

    public string Bucket { get; }

Bucket name explicitly enforced by this policy, that is,
if Google.Cloud.Storage.V1.UrlSigner.PostPolicy.SetField\<TElement, TValue\>(TElement, TValue) has been called
for [BucketName](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.PostPolicyStandardElement#Google_Cloud_Storage_V1_UrlSigner_PostPolicyStandardElement_BucketName).
Otherwise, for instance, if the bucket name was specified as part of the
[Key](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.PostPolicyStandardElement#Google_Cloud_Storage_V1_UrlSigner_PostPolicyStandardElement_Key) element, this will return null.

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

### Fields

    public IReadOnlyDictionary<string, object> Fields { get; }

Collection of fields as defined by this policy.
Post requests enforced by this policy should set, for each
pair in this sequence, the given element to the exact given value.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.collections.generic.ireadonlydictionary-2https://learn.microsoft.com/dotnet/api/system.stringhttps://learn.microsoft.com/dotnet/api/system.object` |   |

## Methods

### ForBucketAndKey(string, string)

    public static UrlSigner.PostPolicy ForBucketAndKey(string bucketName, string exactKeyValue)

Creates a new [UrlSigner.PostPolicy](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.PostPolicy) instance which sets the
[BucketName](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.PostPolicyStandardElement#Google_Cloud_Storage_V1_UrlSigner_PostPolicyStandardElement_BucketName) and requires
an exact match for the [UrlSigner.Key](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner) element.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `bucketName` | `https://learn.microsoft.com/dotnet/api/system.string` The exact value for the bucket name. |
| `exactKeyValue` | `https://learn.microsoft.com/dotnet/api/system.string` The value to match against. 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.PostPolicy` | A new [UrlSigner.PostPolicy](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.PostPolicy) instance. |

### ForBucketAndKeyStartsWith(string, string)

    public static UrlSigner.PostPolicy ForBucketAndKeyStartsWith(string bucketName, string keyPrefix)

Creates a new [UrlSigner.PostPolicy](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.PostPolicy) instance which sets the
[BucketName](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.PostPolicyStandardElement#Google_Cloud_Storage_V1_UrlSigner_PostPolicyStandardElement_BucketName) and requires
a starts-with match for the [Key](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.PostPolicyStandardElement#Google_Cloud_Storage_V1_UrlSigner_PostPolicyStandardElement_Key) element.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `bucketName` | `https://learn.microsoft.com/dotnet/api/system.string` The exact value for the bucket name. |
| `keyPrefix` | `https://learn.microsoft.com/dotnet/api/system.string` The value to match against. 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.PostPolicy` | A new [UrlSigner.PostPolicy](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UrlSigner.PostPolicy) instance. |

### SetCustomField\<TValue\>(PostPolicyCustomElement, string, TValue, Func\<TValue, object\>)

    public void SetCustomField<TValue>(UrlSigner.PostPolicyCustomElement element, string elementName, TValue value, Func<TValue, object> valueToObject = null)

Sets a required field value for `element` of name `elementName`.
If any condition existed on this instance for `element` of name `elementName`
it will be overriden with this required field value.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `element` | `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.PostPolicyCustomElement` The element for which to set a required field value. |
| `elementName` | `https://learn.microsoft.com/dotnet/api/system.string` The custom element name. |
| `value` | `TValue` The value to set the element to. |
| `valueToObject` | `https://learn.microsoft.com/dotnet/api/system.func-2https://learn.microsoft.com/dotnet/api/system.object` The function to convert `value` to the representation which with it should be included in the policy. May be null in which case `TValue` ToString() will be used. |

| **Type Parameter** ||
|---|---|
| **Name** | **Description** |
| `TValue` | The type of the value to set the element to. |

### SetCustomStartsWith(PostPolicyCustomElement, string, string)

    public void SetCustomStartsWith(UrlSigner.PostPolicyCustomElement element, string elementName, string prefix)

Sets a starts-with condition for `element` of name `elementName`.
If any condition existed on this instance for `element` of name `elementName`
it will be overriden with this starts-with condition.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `element` | `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.PostPolicyCustomElement` The element for which to set an starts-with condition. |
| `elementName` | `https://learn.microsoft.com/dotnet/api/system.string` The custom element name. |
| `prefix` | `https://learn.microsoft.com/dotnet/api/system.string` The prefix to validate against. |

### SetField\<TValue\>(PostPolicyStandardElement, TValue)

    public void SetField<TValue>(UrlSigner.PostPolicyStandardElement element, TValue value)

Sets a required field value for `element`.
If any condition existed on this instance for `element` it will
be overriden with this required field value.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `element` | `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.PostPolicyStandardElement` The element for which to set a required field value. |
| `value` | `TValue` The value to set the element to. |

| **Type Parameter** ||
|---|---|
| **Name** | **Description** |
| `TValue` | The type of the value to set the element to. |

### SetRange\<TValue\>(PostPolicyStandardElement, TValue, TValue)

    public void SetRange<TValue>(UrlSigner.PostPolicyStandardElement element, TValue min, TValue max) where TValue : IComparable

Sets a range condition for `element`.
If any condition existed on this instance for `element` it will
be overriden with this range condition.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `element` | `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.PostPolicyStandardElement` The element for which to set a range condition. |
| `min` | `TValue` The range lower bound. |
| `max` | `TValue` The range upper bound. |

| **Type Parameter** ||
|---|---|
| **Name** | **Description** |
| `TValue` | The type of the values defining the range. |

### SetStartsWith(PostPolicyStandardElement, string)

    public void SetStartsWith(UrlSigner.PostPolicyStandardElement element, string prefix)

Sets a starts-with condition for `element`.
If any condition existed on this instance for `element` it will
be overriden with this starts-with condition.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `element` | `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.PostPolicyStandardElement` The element for which to set an starts-with condition. |
| `prefix` | `https://learn.microsoft.com/dotnet/api/system.string` The prefix to validate against. |