Table of Contents

Struct R2StorageClass

Namespace
Cloudflare.NET.Accounts.Models
Assembly
Cloudflare.NET.dll

Represents a storage class for R2 objects.

Storage classes determine the cost and access characteristics of stored objects. Different classes offer trade-offs between storage cost and retrieval latency/cost.

[JsonConverter(typeof(ExtensibleEnumConverter<R2StorageClass>))]
public readonly struct R2StorageClass : IExtensibleEnum<R2StorageClass>, IEquatable<R2StorageClass>
Implements
Inherited Members

Examples

// Using a known storage class with IntelliSense
var storageClass = R2StorageClass.InfrequentAccess;

// Using implicit conversion from string
R2StorageClass customClass = "new-storage-class";

// In lifecycle transitions
new StorageClassTransition(
  LifecycleCondition.AfterDays(30),
  R2StorageClass.InfrequentAccess
);

Remarks

This is an extensible enum that provides IntelliSense for known values while allowing custom values for new storage classes that may be added to the Cloudflare API in the future.

The storage class can be set at the bucket level (as a default for new objects) or specified per-object during upload. Lifecycle rules can also transition objects between storage classes.

Constructors

R2StorageClass(string)

Creates a new R2StorageClass with the specified value.

public R2StorageClass(string value)

Parameters

value string

The string value representing the storage class.

Exceptions

ArgumentNullException

Thrown when value is null.

Properties

InfrequentAccess

Infrequent Access storage class for less frequently accessed data.

public static R2StorageClass InfrequentAccess { get; }

Property Value

R2StorageClass

Remarks

Offers lower storage costs compared to Standard, but with retrieval fees and a minimum storage duration. Ideal for backup data, disaster recovery, and data accessed less than once per month.

Pricing: Lower storage rates with per-GB retrieval fees. Objects have a minimum billable storage duration.

Standard

Standard storage class for frequently accessed data.

public static R2StorageClass Standard { get; }

Property Value

R2StorageClass

Remarks

This is the default storage class offering low-latency access with no minimum storage duration. Ideal for frequently accessed data, active content, and data requiring immediate retrieval.

Pricing: Standard storage rates with no retrieval fees.

Value

Gets the underlying string value of this storage class.

public string Value { get; }

Property Value

string

Methods

Create(string)

Creates a new instance of the extensible enum from the specified string value.

public static R2StorageClass Create(string value)

Parameters

value string

The string value to wrap.

Returns

R2StorageClass

A new instance of R2StorageClass containing the specified value.

Equals(R2StorageClass)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(R2StorageClass other)

Parameters

other R2StorageClass

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

GetHashCode()

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

ToString()

Returns the fully qualified type name of this instance.

public override string ToString()

Returns

string

The fully qualified type name.

Operators

operator ==(R2StorageClass, R2StorageClass)

Determines whether two R2StorageClass values are equal.

public static bool operator ==(R2StorageClass left, R2StorageClass right)

Parameters

left R2StorageClass
right R2StorageClass

Returns

bool

implicit operator string(R2StorageClass)

Implicitly converts an R2StorageClass to its string value.

public static implicit operator string(R2StorageClass storageClass)

Parameters

storageClass R2StorageClass

The storage class to convert.

Returns

string

implicit operator R2StorageClass(string)

Implicitly converts a string to an R2StorageClass.

public static implicit operator R2StorageClass(string value)

Parameters

value string

The string value to convert.

Returns

R2StorageClass

operator !=(R2StorageClass, R2StorageClass)

Determines whether two R2StorageClass values are not equal.

public static bool operator !=(R2StorageClass left, R2StorageClass right)

Parameters

left R2StorageClass
right R2StorageClass

Returns

bool

See Also