Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ pub enum Attribute {
///
/// See [Cache-Control](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control)
CacheControl,
/// Specifies the storage class of the object.
///
/// See [AWS](https://aws.amazon.com/s3/storage-classes/),
/// [GCP](https://cloud.google.com/storage/docs/storage-classes), and
/// [Azure](https://learn.microsoft.com/en-us/rest/api/storageservices/set-blob-tier).
/// `StorageClass` is used as the name for this attribute because 2 of the 3 storage providers
/// use that name
StorageClass,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I verified that adding a new enum variant is not a breaking API change as this enum is marked #[non_exhaustive]

/// Specifies a user-defined metadata field for the object
///
/// The String is a user-defined key
Expand Down
2 changes: 2 additions & 0 deletions src/aws/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const VERSION_HEADER: &str = "x-amz-version-id";
const SHA256_CHECKSUM: &str = "x-amz-checksum-sha256";
const USER_DEFINED_METADATA_HEADER_PREFIX: &str = "x-amz-meta-";
const ALGORITHM: &str = "x-amz-checksum-algorithm";
const STORAGE_CLASS: &str = "x-amz-storage-class";

/// A specialized `Error` for object store-related errors
#[derive(Debug, thiserror::Error)]
Expand Down Expand Up @@ -373,6 +374,7 @@ impl Request<'_> {
has_content_type = true;
builder.header(CONTENT_TYPE, v.as_ref())
}
Attribute::StorageClass => builder.header(STORAGE_CLASS, v.as_ref()),
Attribute::Metadata(k_suffix) => builder.header(
&format!("{USER_DEFINED_METADATA_HEADER_PREFIX}{k_suffix}"),
v.as_ref(),
Expand Down
2 changes: 2 additions & 0 deletions src/azure/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ use std::time::Duration;
use url::Url;

const VERSION_HEADER: &str = "x-ms-version-id";
const ACCESS_TIER_HEADER: &str = "x-ms-access-tier";
const USER_DEFINED_METADATA_HEADER_PREFIX: &str = "x-ms-meta-";
static MS_CACHE_CONTROL: HeaderName = HeaderName::from_static("x-ms-blob-cache-control");
static MS_CONTENT_TYPE: HeaderName = HeaderName::from_static("x-ms-blob-content-type");
Expand Down Expand Up @@ -242,6 +243,7 @@ impl PutRequest<'_> {
has_content_type = true;
builder.header(&MS_CONTENT_TYPE, v.as_ref())
}
Attribute::StorageClass => builder.header(ACCESS_TIER_HEADER, v.as_ref()),
Attribute::Metadata(k_suffix) => builder.header(
&format!("{USER_DEFINED_METADATA_HEADER_PREFIX}{k_suffix}"),
v.as_ref(),
Expand Down
2 changes: 2 additions & 0 deletions src/gcp/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ use std::sync::Arc;
const VERSION_HEADER: &str = "x-goog-generation";
const DEFAULT_CONTENT_TYPE: &str = "application/octet-stream";
const USER_DEFINED_METADATA_HEADER_PREFIX: &str = "x-goog-meta-";
const STORAGE_CLASS: &str = "x-goog-storage-class";

static VERSION_MATCH: HeaderName = HeaderName::from_static("x-goog-if-generation-match");

Expand Down Expand Up @@ -201,6 +202,7 @@ impl Request<'_> {
has_content_type = true;
builder.header(CONTENT_TYPE, v.as_ref())
}
Attribute::StorageClass => builder.header(STORAGE_CLASS, v.as_ref()),
Attribute::Metadata(k_suffix) => builder.header(
&format!("{USER_DEFINED_METADATA_HEADER_PREFIX}{k_suffix}"),
v.as_ref(),
Expand Down
4 changes: 4 additions & 0 deletions src/http/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ impl Client {
has_content_type = true;
builder.header(CONTENT_TYPE, v.as_ref())
}
Attribute::StorageClass => {
tracing::warn!("StorageClass attribute not supported on HTTP client as header key is unknown");
builder
}
// Ignore metadata attributes
Attribute::Metadata(_) => builder,
};
Expand Down
Loading