Table of Contents

Class PresignedPutRequest

Namespace
Cloudflare.NET.R2.Models
Assembly
Cloudflare.NET.R2.dll

Defines the parameters for creating a presigned PUT URL, which allows for direct, secure uploads.

public record PresignedPutRequest : IEquatable<PresignedPutRequest>
Inheritance
PresignedPutRequest
Implements
Inherited Members

Constructors

PresignedPutRequest(string, TimeSpan, long, string, IEnumerable<S3PostCondition>?, IReadOnlyDictionary<string, string>?, UploadChecksum?, string?)

Defines the parameters for creating a presigned PUT URL, which allows for direct, secure uploads.

public PresignedPutRequest(string Key, TimeSpan ExpiresAfter, long ContentLength, string ContentType, IEnumerable<S3PostCondition>? Conditions = null, IReadOnlyDictionary<string, string>? HeadersToSign = null, UploadChecksum? Checksum = null, string? CacheControl = null)

Parameters

Key string

The object key (path) where the file will be stored in the bucket.

ExpiresAfter TimeSpan

The duration for which the presigned URL will be valid.

ContentLength long

The exact size of the file to be uploaded, in bytes. This is enforced by R2.

ContentType string

The MIME type of the file to be uploaded (e.g., "image/jpeg"). This is enforced by R2.

Conditions IEnumerable<S3PostCondition>

Optional S3 POST policy conditions to enforce additional constraints on the upload.

HeadersToSign IReadOnlyDictionary<string, string>

An optional dictionary of additional headers to include in the signature, enforcing them on the client-side upload.

Checksum UploadChecksum

An optional digest to bind the uploaded bytes to. Its algorithm's header is signed into the URL, the client must send it, and R2 rejects the upload with 400 BadDigest (storing nothing) when the arriving bytes do not hash to the stated digest. All five R2ChecksumAlgorithm values are verified on a single-part PUT. When the same header also appears in HeadersToSign, this parameter wins.

CacheControl string

An optional Cache-Control value to store on the object. The header is signed into the URL, so the client must send it with exactly this value or R2 answers 403; R2 persists the stored value and serves it on every GET, which drives edge and browser caching. Passing null or a blank string leaves the header unset. When the same header also appears in HeadersToSign, this parameter wins.

Properties

CacheControl

An optional Cache-Control value to store on the object. The header is signed into the URL, so the client must send it with exactly this value or R2 answers 403; R2 persists the stored value and serves it on every GET, which drives edge and browser caching. Passing null or a blank string leaves the header unset. When the same header also appears in HeadersToSign, this parameter wins.

public string? CacheControl { get; init; }

Property Value

string

Checksum

An optional digest to bind the uploaded bytes to. Its algorithm's header is signed into the URL, the client must send it, and R2 rejects the upload with 400 BadDigest (storing nothing) when the arriving bytes do not hash to the stated digest. All five R2ChecksumAlgorithm values are verified on a single-part PUT. When the same header also appears in HeadersToSign, this parameter wins.

public UploadChecksum? Checksum { get; init; }

Property Value

UploadChecksum

Conditions

Optional S3 POST policy conditions to enforce additional constraints on the upload.

public IEnumerable<S3PostCondition>? Conditions { get; init; }

Property Value

IEnumerable<S3PostCondition>

ContentLength

The exact size of the file to be uploaded, in bytes. This is enforced by R2.

public long ContentLength { get; init; }

Property Value

long

ContentType

The MIME type of the file to be uploaded (e.g., "image/jpeg"). This is enforced by R2.

public string ContentType { get; init; }

Property Value

string

ExpiresAfter

The duration for which the presigned URL will be valid.

public TimeSpan ExpiresAfter { get; init; }

Property Value

TimeSpan

HeadersToSign

An optional dictionary of additional headers to include in the signature, enforcing them on the client-side upload.

public IReadOnlyDictionary<string, string>? HeadersToSign { get; init; }

Property Value

IReadOnlyDictionary<string, string>

Key

The object key (path) where the file will be stored in the bucket.

public string Key { get; init; }

Property Value

string