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 UploadObjectOptions

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

Options for `UploadObject` operations.

## Inheritance

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

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

## Fields

### MinimumChunkSize

    public const int MinimumChunkSize = 262144

The minimum chunk size for uploading.

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

## Properties

### ChunkSize

    public int? ChunkSize { get; set; }

The chunk size to use for each request. When setting to a non-null value, this
must be a positive multiple of [MinimumChunkSize](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UploadObjectOptions#Google_Cloud_Storage_V1_UploadObjectOptions_MinimumChunkSize).

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

### EncryptionKey

    public EncryptionKey EncryptionKey { get; set; }

The customer-supplied encryption key to use for this operation. If this property is null, the [EncryptionKey](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.StorageClient#Google_Cloud_Storage_V1_StorageClient_EncryptionKey)
will be used instead. Use [None](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.EncryptionKey#Google_Cloud_Storage_V1_EncryptionKey_None) to remove encryption headers from this request.

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

### IfGenerationMatch

    public long? IfGenerationMatch { get; set; }

Precondition for upload: the object is only uploaded if the existing object's
generation matches the given value.

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

**Example**

    var client = StorageClient.Create();

    using var sourceStream = new MemoryStream(Encoding.UTF8.GetBytes("Sample data"));
    var destination = "greetings/hello.txt";
    var contentType = "text/plain";

    // An IfGenerationMatch of 0 means "only if the object doesn't already exist".
    var options = new UploadObjectOptions { IfGenerationMatch = 0 };

    bool existed = false;
    try
    {
        client.UploadObject(bucketName, destination, contentType, sourceStream, options);
    }
    catch (GoogleApiException e) when (e.HttpStatusCode == HttpStatusCode.PreconditionFailed)
    {
        // The object already existed.
        existed = true;
    }

    // Log or otherwise use the information about whether the object already existed.

### IfGenerationNotMatch

    public long? IfGenerationNotMatch { get; set; }

Precondition for upload: the object is only uploaded if the existing object's
generation does not match the given value.

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

### IfMetagenerationMatch

    public long? IfMetagenerationMatch { get; set; }

Precondition for upload: the object is only uploaded if the existing object's
meta-generation matches the given value.

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

### IfMetagenerationNotMatch

    public long? IfMetagenerationNotMatch { get; set; }

Precondition for upload: the object is only uploaded if the existing object's
meta-generation does not match the given value.

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

### KmsKeyName

    public string KmsKeyName { get; set; }

The name of the Cloud KMS key to use to encrypt the object.

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

**Remarks** Currently, either customer-supplied encryption or a Cloud KMS key can be used, but not both.
If this property is null and customer-supplied encryption is not being used,
the bucket encryption defaults will be used to determine the encryption for the object.
If this property is non-null and the client object has a default encryption key, the [EncryptionKey](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UploadObjectOptions#Google_Cloud_Storage_V1_UploadObjectOptions_EncryptionKey) property
of this options object must be set to [None](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.EncryptionKey#Google_Cloud_Storage_V1_EncryptionKey_None) to make the intention clear.

### Origin

    public string Origin { get; set; }

If set, an Origin header is included when initiating the resumable upload. This allows for Cross-Origin
Resource Sharing, as documented at <https://cloud.google.com/storage/docs/cross-origin>.

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

### PredefinedAcl

    public PredefinedObjectAcl? PredefinedAcl { get; set; }

A pre-defined ACL for simple access control scenarios.

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

### Projection

    public Projection? Projection { get; set; }

The projection of the uploaded object to retrieve.

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

### UploadValidationMode

    public UploadValidationMode? UploadValidationMode { get; set; }

Specifies how the upload should be validated for data integrity.
If this property is null, this is equivalent to [DeleteAndThrow](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Storage.V1/latest/Google.Cloud.Storage.V1.UploadValidationMode#Google_Cloud_Storage_V1_UploadValidationMode_DeleteAndThrow).

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

**Remarks** The hash is only validated at the end of the upload, after the object has been created.
An exception is thrown if it's incorrect, but the object will still exist unless
the validation action deletes it.

### UserProject

    public string UserProject { get; set; }

If set, this is the ID of the project which will be billed for the request.
The caller must have suitable permissions for the project being billed.

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