Skip to main content

S3

Struct S3 

pub struct S3 { /* private fields */ }
Available on crate feature services-s3 only.
Expand description

Aws S3 and compatible services (including minio, digitalocean space, Tencent Cloud Object Storage(COS) and so on) support. For more information about s3-compatible services, refer to Compatible Services.

§Capabilities

Depending on its configuration and the backing system, this service can expose:

  • create_dir
  • stat
  • read
  • write
  • delete
  • list
  • copy
  • restore
  • rename
  • presign

Inspect the effective capability set with opendal_core::Operator::info and opendal_core::OperatorInfo::capability after building an operator.

§Read and stat checksums

For signed requests to standard AWS S3 endpoints, use opendal_core::Operator::stat_with or opendal_core::Operator::reader_with with .checksum(true) to request stored full-object checksums. Stat returns the metadata directly. A reader that observes a full-object response first exposes its metadata through opendal_core::Reader::metadata. opendal_core::Operator::read_with returns the bytes.

OpenDAL exposes full-object CRC-64/NVME, CRC-32C, and SHA-256 checksums when S3 returns them. A ranged read can expose a checksum when the response covers the whole object. Composite checksums and responses that cover only part of the object leave opendal_core::Metadata::checksum empty. OpenDAL omits checksum mode by default and for presigned requests, anonymous access, directory buckets, and S3-compatible endpoints and presets.

§Object restoration

S3 restoration requires bucket versioning. opendal_core::Operator::restore removes the current delete marker. Calling it on an already-live object succeeds. It does not scan or remove older marker versions. If no live object or current delete marker exists, it returns opendal_core::ErrorKind::NotFound.

Use opendal_core::Operator::restore_with to promote a specific version:

op.restore_with("path/to/file")
    .version(version)
    .await?;

Add .if_not_exists(true) when a selected version must not overwrite an object recreated by another writer. This condition requires an explicit version.

§Write verification

On general-purpose AWS S3 buckets, use opendal_core::WriteChecksum::Any or opendal_core::WriteChecksum::Fast to compute and verify a full-object CRC-64/NVME checksum. Explicit algorithm and expected checksum requests support CRC-32C and CRC-64/NVME. The write returns the confirmed checksum in opendal_core::Metadata::checksum for both a single PUT and multipart upload.

On S3 Express One Zone directory buckets, signed writes use full-object CRC-32C for Any and Fast. Explicit algorithm and expected checksum requests also support CRC-32C. The write returns the confirmed checksum for both a single PUT and multipart upload. Directory buckets reject other requested algorithms with opendal_core::ErrorKind::Unsupported.

OpenDAL returns Unsupported for checksum intents on append writes and on S3 Express presigned writes. The MinIO, SeaweedFS, and Ceph RADOS Gateway presets also accept write checksum intents. See each preset’s documentation for its supported algorithms and server behavior.

A per-write intent takes precedence over crate::S3Config::checksum_algorithm for HTTP checksum headers. The configured algorithm still disables native writer copy, and configuring md5 still limits writes to a single PUT.

To apply a checksum policy to an entire operator, enable the services-s3 and layers-checksum features on opendal and attach ChecksumLayer. The default policy requests a fast native checksum for writes without an explicit checksum intent and verifies available whole-object checksums on reads.

ⓘ
use opendal::layers::ChecksumLayer;
use opendal::services::S3;
use opendal::{Operator, Result};

#[tokio::main]
async fn main() -> Result<()> {
    let op = Operator::new(S3::default().bucket("example-bucket").region("us-west-2"))?
        .layer(ChecksumLayer::new());

    op.write("example.txt", "hello").await?;
    let data = op.read("example.txt").await?;
    assert_eq!(data.to_vec(), b"hello");
    Ok(())
}

§Configuration

Use crate::S3Config for serializable configuration and this builder’s methods for direct construction. The field and method documentation defines accepted values, defaults, and environment interaction.

§AWS container credentials

The default AWS credential chain already reads ambient container credential settings. The container credential options expose the same provider settings through typed builder methods, serialized configuration, and URI options. Setting any of these options replaces the ECS slot in the default chain without changing that slot’s position.

Endpoint selection follows this order:

  1. container_credentials_endpoint
  2. container_credentials_relative_uri
  3. AWS_CONTAINER_CREDENTIALS_FULL_URI
  4. AWS_CONTAINER_CREDENTIALS_RELATIVE_URI

container_metadata_uri_override changes the base URI for relative endpoints only and does not select an endpoint by itself. Authorization token selection follows this order:

  1. container_authorization_token
  2. container_authorization_token_file
  3. AWS_CONTAINER_AUTHORIZATION_TOKEN
  4. AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE

These options configure the existing ECS slot; they do not force it ahead of environment, profile, SSO, web identity, or external process providers. Configured static credentials retain their higher priority. crate::S3::role_arn continues to use the assembled provider as the source for role assumption, and crate::S3::credential_provider_chain continues to replace the assembled chain. crate::S3::disable_config_load disables automatic endpoint loading and the environment, profile, SSO, web-identity, and external process credential slots. Region environment lookup and compute metadata credential providers, including container credentials and EC2 instance metadata, remain enabled.

§S3 Express One Zone

OpenDAL recognizes valid AWS directory bucket names on AWS endpoints and automatically uses the bucket’s virtual-hosted zonal endpoint. Set the bucket name and Region to connect with your configured AWS credentials.

use opendal_core::Operator;
use opendal_core::Result;
use opendal_service_s3::S3;

fn build_operator() -> Result<Operator> {
    Operator::new(
        S3::default()
            .bucket("example--usw2-az1--x-s3")
            .region("us-west-2"),
    )
}

This automatic behavior applies only to AWS endpoints. S3-compatible services retain the existing IAM authentication behavior.

In the standard AWS partition, the zonal endpoint has the form https://<bucket>.s3express-<zone-id>.<region>.amazonaws.com. You can omit the endpoint or supply a matching AWS regional or zonal endpoint. OpenDAL also accepts s3.amazonaws.com in the standard AWS partition. OpenDAL rejects mismatched or unsupported AWS endpoints, including dual-stack endpoints, with opendal_core::ErrorKind::ConfigInvalid.

Grant s3express:CreateSession on the bucket and allow ReadWrite sessions. OpenDAL uses the configured AWS credentials to call CreateSession and refreshes sessions automatically. It signs CopyObject, UploadPartCopy, and presigned requests with the underlying IAM credentials. See the AWS CreateSession API reference.

§Directory bucket behavior

  • Listing. By default, OpenDAL uses ListObjectsV2 with / as the delimiter. AWS accepts only / as a delimiter and requires nonempty request prefixes to end in /. OpenDAL’s default operator filters directory listings for partial prefixes and walks directories for recursive listings, which can require additional requests. Leave disable_list_objects_v2 unset. Directory buckets do not support start_after or guarantee lexicographical order. See the AWS ListObjectsV2 API reference.
  • Versioning and restore. AWS directory buckets do not support S3 Versioning. OpenDAL disables version-specific stat, read, delete, and copy-source options, listing versions or delete markers, and restore. See the AWS PutBucketVersioning API reference.
  • Writes. OpenDAL supports conditional writes with If-Match and If-None-Match: *, as well as appending to objects in the EXPRESS_ONEZONE storage class. The service does not advertise write_with_content_encoding for directory buckets. See the AWS PutObject API reference.

§Temporary security credentials

OpenDAL now provides support for S3 temporary security credentials in IAM.

The way to take advantage of this feature is to build your S3 backend with Builder::session_token.

But OpenDAL will not refresh the temporary security credentials, please keep in mind to refresh those credentials in time.

§Server Side Encryption

OpenDAL provides full support of S3 Server Side Encryption(SSE) features.

The easiest way to configure them is to use helper functions like

  • SSE-KMS: server_side_encryption_with_aws_managed_kms_key
  • SSE-KMS: server_side_encryption_with_customer_managed_kms_key
  • SSE-S3: server_side_encryption_with_s3_key
  • SSE-C: server_side_encryption_with_customer_key

If those functions don’t fulfill need, low-level options are also provided:

  • Use service managed kms key
    • server_side_encryption="aws:kms"
  • Use customer provided kms key
    • server_side_encryption="aws:kms"
    • server_side_encryption_aws_kms_key_id="your-kms-key"
  • Use S3 managed key
    • server_side_encryption="AES256"
  • Use customer key
    • server_side_encryption_customer_algorithm="AES256"
    • server_side_encryption_customer_key="base64-of-your-aes256-key"
    • server_side_encryption_customer_key_md5="base64-of-your-aes256-key-md5"

After SSE have been configured, all requests send by this backed will attach those headers.

Reference: Protecting data using server-side encryption

§Example

§Via Builder

§Basic Setup

use opendal_core::Operator;
use opendal_core::Result;
use opendal_service_s3::S3;

#[tokio::main]
async fn main() -> Result<()> {
    // Create s3 backend builder.
    let mut builder = S3::default()
      // Set the root for s3, all operations will happen under this root.
      //
      // NOTE: the root must be absolute path.
      .root("/path/to/dir")
      // Set the bucket name. This is required.
      .bucket("test")
      // Set the signing region. Compatible services define their own region rules.
      .region("us-east-1")
      // Set the endpoint.
      //
      // For examples:
      // - "https://s3.amazonaws.com"
      // - "http://127.0.0.1:9000"
      // - "https://oss-ap-northeast-1.aliyuncs.com"
      // - "https://cos.ap-seoul.myqcloud.com"
      //
      // Default to "https://s3.amazonaws.com"
      .endpoint("https://s3.amazonaws.com")
      // Set the access_key_id and secret_access_key.
      //
      // OpenDAL will try load credential from the env.
      // If credential not set and no valid credential in env, OpenDAL will
      // send request without signing like anonymous user.
      .access_key_id("access_key_id")
      .secret_access_key("secret_access_key");

    let op: Operator = Operator::new(builder)?;

    Ok(())
}

§S3 with SSE-C

use log::info;
use opendal_core::Operator;
use opendal_core::Result;
use opendal_service_s3::S3;

#[tokio::main]
async fn main() -> Result<()> {
    let mut builder = S3::default()
      .root("/path/to/dir")
      .bucket("test")
      .region("us-east-1")
      .endpoint("https://s3.amazonaws.com")
      .access_key_id("access_key_id")
      .secret_access_key("secret_access_key")
      // Enable SSE-C
      .server_side_encryption_with_customer_key("AES256", "customer_key".as_bytes());

    let op = Operator::new(builder)?;
    info!("operator: {:?}", op);

    // Writing your testing code here.

    Ok(())
}

§S3 with SSE-KMS and aws managed kms key

use log::info;
use opendal_core::Operator;
use opendal_core::Result;
use opendal_service_s3::S3;

#[tokio::main]
async fn main() -> Result<()> {
    let mut builder = S3::default()
      // Setup builders
      .root("/path/to/dir")
      .bucket("test")
      .region("us-east-1")
      .endpoint("https://s3.amazonaws.com")
      .access_key_id("access_key_id")
      .secret_access_key("secret_access_key")
      // Enable SSE-KMS with aws managed kms key
      .server_side_encryption_with_aws_managed_kms_key();

    let op = Operator::new(builder)?;
    info!("operator: {:?}", op);

    // Writing your testing code here.

    Ok(())
}

§S3 with SSE-KMS and customer managed kms key

use log::info;
use opendal_core::Operator;
use opendal_core::Result;
use opendal_service_s3::S3;

#[tokio::main]
async fn main() -> Result<()> {
    let mut builder = S3::default()
      // Setup builders
      .root("/path/to/dir")
      .bucket("test")
      .region("us-east-1")
      .endpoint("https://s3.amazonaws.com")
      .access_key_id("access_key_id")
      .secret_access_key("secret_access_key")
      // Enable SSE-KMS with customer managed kms key
      .server_side_encryption_with_customer_managed_kms_key("aws_kms_key_id");

    let op = Operator::new(builder)?;
    info!("operator: {:?}", op);

    // Writing your testing code here.

    Ok(())
}

§S3 with SSE-S3

use log::info;
use opendal_core::Operator;
use opendal_core::Result;
use opendal_service_s3::S3;

#[tokio::main]
async fn main() -> Result<()> {
    let mut builder = S3::default()
      // Setup builders
      .root("/path/to/dir")
      .bucket("test")
      .region("us-east-1")
      .endpoint("https://s3.amazonaws.com")
      .access_key_id("access_key_id")
      .secret_access_key("secret_access_key")
      // Enable SSE-S3
      .server_side_encryption_with_s3_key();

    let op = Operator::new(builder)?;
    info!("operator: {:?}", op);

    // Writing your testing code here.

    Ok(())
}

§S3 with default ACL

use log::info;
use opendal_core::Operator;
use opendal_core::Result;
use opendal_service_s3::S3;

#[tokio::main]
async fn main() -> Result<()> {
    let mut builder = S3::default()
      // Setup builders
      .root("/path/to/dir")
      .bucket("test")
      .region("us-east-1")
      .endpoint("https://s3.amazonaws.com")
      .access_key_id("access_key_id")
      .secret_access_key("secret_access_key")
      // Enable public-read ACL
      .default_acl("public-read");

    let op = Operator::new(builder)?;
    info!("operator: {:?}", op);

    // New objects will be created with public-read ACL

    Ok(())
}

§Compatible Services

OpenDAL provides provider presets for services with a maintained, narrow configuration contract:

  • Use crate::R2 or the r2 scheme for Cloudflare R2.
  • Use crate::Minio or the minio scheme for MinIO deployments.
  • Use crate::Akamai or the akamai scheme for Akamai Cloud Object Storage.
  • Use crate::CephRgw or the ceph-rgw scheme for Ceph RADOS Gateway.
  • Use crate::Exoscale or the exoscale scheme for Exoscale Simple Object Storage.
  • Use crate::Garage or the garage scheme for Garage deployments.
  • Use crate::Hetzner or the hetzner scheme for Hetzner Object Storage.
  • Use crate::IbmCos or the ibm-cos scheme for IBM Cloud Object Storage.
  • Use crate::IdriveE2 or the idrive-e2 scheme for IDrive e2.
  • Use crate::Ionos or the ionos scheme for IONOS Cloud Object Storage.
  • Use crate::Neon or the neon scheme for Neon Object Storage.
  • Use crate::Oci or the oci scheme for Oracle Cloud Infrastructure Object Storage.
  • Use crate::Ovhcloud or the ovhcloud scheme for OVHcloud Object Storage.
  • Use crate::Qingstor or the qingstor scheme for QingStor Object Storage.
  • Use crate::Rustfs or the rustfs scheme for RustFS deployments.
  • Use crate::Scaleway or the scaleway scheme for Scaleway Object Storage.
  • Use crate::Seaweedfs or the seaweedfs scheme for SeaweedFS S3 gateways.
  • Use crate::Spaces or the spaces scheme for DigitalOcean Spaces.
  • Use crate::Storj or the storj scheme for the Storj-hosted S3 Gateway.
  • Use crate::Supabase or the supabase scheme for Supabase Storage.
  • Use crate::Tigris or the tigris scheme for Tigris.
  • Use crate::Wasabi or the wasabi scheme for Wasabi Object Storage.

The presets own provider defaults and validation. Their capabilities describe the shared S3 implementation. Check the provider guides for endpoint-specific limits. Presets built on the shared credential chain accept a provider’s key pair explicitly or load it from the standard AWS environment variables or shared credentials file. Explicit credentials take precedence. If a preset points to a third-party endpoint and your process also holds AWS credentials, set disable_config_load = true to use only explicitly configured keys. Use the generic crate::S3 builder for AWS S3, for compatible services without a built-in preset, or when an application requires S3 options outside a preset’s contract.

§AWS S3

AWS S3 is the default implementations of s3 services. Only bucket is required.

ⓘ
builder.bucket("<bucket_name>");

§Native services and S3 presets

The facade registers the native services under their existing schemes. The S3 presets use separate schemes and their own Cargo features. Enable the corresponding preset feature to select an S3 API explicitly.

  • Use crate::B2S3 or the b2-s3 scheme for Backblaze B2.
  • Use crate::CosS3 or the cos-s3 scheme for Tencent Cloud COS.
  • Use crate::GcsS3 or the gcs-s3 scheme for Google Cloud Storage.
  • Use crate::LakefsS3 or the lakefs-s3 scheme for the lakeFS S3 Gateway.
  • Use crate::ObsS3 or the obs-s3 scheme for Huawei Cloud OBS in the China public cloud.
  • Use crate::OssS3 or the oss-s3 scheme for Alibaba Cloud OSS.
  • Use crate::SwiftS3api or the swift-s3api scheme for OpenStack Swift s3api.
  • Use crate::TosS3 or the tos-s3 scheme for Volcengine and BytePlus TOS.

Applications can override a scheme in the process-wide operator registry. For example, enable services-gcs-s3 in the facade and register GcsS3 for gcs after initializing the default registry.

ⓘ
use opendal::{Operator, OperatorRegistry, services::GcsS3};

opendal::init_default_registry();
OperatorRegistry::get().register::<GcsS3>("gcs");
let op = Operator::from_uri("gcs://example-bucket/prefix")?;

After an override, URIs use the selected preset’s fields and URI syntax. In particular, the Swift and lakeFS presets use the URI authority for the bucket and take the gateway URL in the endpoint option. The native Swift and lakeFS schemes use the authority for the endpoint.

§Copy with metadata replacement

copy_with_user_metadata, copy_with_content_type and copy_with_content_language are enabled for every endpoint. They send CopyObject with x-amz-metadata-directive: REPLACE, and a multipart copy sets the metadata on CreateMultipartUpload.

The behavior tests for these options pass on AWS S3, Garage v2.1.0, SeaweedFS 4.52 and Silo. No known service rejects them so far. The other services in this list, and S3 Express One Zone directory buckets, are not verified. If a service ignores or rejects the directive, override the three capabilities to false:

ⓘ
let op = Operator::new(builder)?.layer(CapabilityOverrideLayer::new(|mut cap| {
    cap.copy_with_user_metadata = false;
    cap.copy_with_content_type = false;
    cap.copy_with_content_language = false;
    cap
}));

Implementations§

§

impl S3Builder

pub fn root(self, root: &str) -> S3Builder

Set root of this backend.

All operations will happen under this root.

pub fn bucket(self, bucket: &str) -> S3Builder

Set bucket name of this backend.

pub fn endpoint(self, endpoint: &str) -> S3Builder

Set endpoint of this backend.

Endpoint must be full uri, e.g.

  • AWS S3: https://s3.amazonaws.com or https://s3.{region}.amazonaws.com
  • Cloudflare R2: https://<ACCOUNT_ID>.r2.cloudflarestorage.com
  • Aliyun OSS: https://{region}.aliyuncs.com
  • Tencent COS: https://cos.{region}.myqcloud.com
  • Minio: http://127.0.0.1:9000

If user inputs endpoint without scheme like “s3.amazonaws.com”, we will prepend “https://” before it.

pub fn region(self, region: &str) -> S3Builder

Region represent the signing region of this endpoint. This is required if you are using the default AWS S3 endpoint.

If using a custom endpoint,

  • If region is set, we will take user’s input first.
  • If not, we will try to load it from environment.

pub fn default_region(self, region: &str) -> S3Builder

Set the fallback signing region.

OpenDAL uses this value only when region, AWS_REGION, and AWS_DEFAULT_REGION do not supply a region. Without any region, building the service returns ErrorKind::ConfigInvalid.

pub fn profile(self, profile: &str) -> S3Builder

Set the AWS profile used by the default credential provider chain.

The configured profile takes precedence over the AWS_PROFILE environment variable and applies to shared AWS config and credentials files, SSO, and external process credentials.

This setting has no effect when Self::disable_config_load is set or when Self::credential_provider_chain replaces the default chain.

pub fn access_key_id(self, v: &str) -> S3Builder

Set access_key_id of this backend.

  • If access_key_id is set, we will take user’s input first.
  • If not, we will try to load it from environment.

pub fn secret_access_key(self, v: &str) -> S3Builder

Set secret_access_key of this backend.

  • If secret_access_key is set, we will take user’s input first.
  • If not, we will try to load it from environment.

pub fn role_arn(self, v: &str) -> S3Builder

Set role_arn for this backend.

If role_arn is set, we will use already known config as source credential to assume role with role_arn.

pub fn external_id(self, v: &str) -> S3Builder

Set external_id for this backend.

pub fn role_session_name(self, v: &str) -> S3Builder

Set role_session_name for this backend.

pub fn assume_role_duration_seconds(self, v: u32) -> S3Builder

Set assume_role_duration_seconds for this backend.

pub fn assume_role_session_tags( self, tags: HashMap<String, String>, ) -> S3Builder

Set assume_role_session_tags for this backend.

pub fn default_storage_class(self, v: &str) -> S3Builder

Set default storage_class for this backend.

Available values:

  • DEEP_ARCHIVE
  • GLACIER
  • GLACIER_IR
  • INTELLIGENT_TIERING
  • ONEZONE_IA
  • OUTPOSTS
  • REDUCED_REDUNDANCY
  • STANDARD
  • STANDARD_IA

pub fn server_side_encryption(self, v: &str) -> S3Builder

Set server_side_encryption for this backend.

Available values: AES256, aws:kms.

§Note

This function is the low-level setting for SSE related features.

SSE related options should be set carefully to make them works. Please use server_side_encryption_with_* helpers if even possible.

pub fn server_side_encryption_aws_kms_key_id(self, v: &str) -> S3Builder

Set server_side_encryption_aws_kms_key_id for this backend

  • If server_side_encryption set to aws:kms, and server_side_encryption_aws_kms_key_id is not set, S3 will use aws managed kms key to encrypt data.
  • If server_side_encryption set to aws:kms, and server_side_encryption_aws_kms_key_id is a valid kms key id, S3 will use the provided kms key to encrypt data.
  • If the server_side_encryption_aws_kms_key_id is invalid or not found, an error will be returned.
  • If server_side_encryption is not aws:kms, setting server_side_encryption_aws_kms_key_id is a noop.
§Note

This function is the low-level setting for SSE related features.

SSE related options should be set carefully to make them works. Please use server_side_encryption_with_* helpers if even possible.

pub fn server_side_encryption_bucket_key_enabled( self, enabled: bool, ) -> S3Builder

Control S3 Bucket Keys for SSE-KMS writes and copies.

true enables Bucket Keys for destination objects; false explicitly disables them. If this method is not called, objects inherit the bucket setting. This option does not change the bucket’s configuration.

pub fn server_side_encryption_customer_algorithm(self, v: &str) -> S3Builder

Set server_side_encryption_customer_algorithm for this backend.

Available values: AES256.

§Note

This function is the low-level setting for SSE related features.

SSE related options should be set carefully to make them works. Please use server_side_encryption_with_* helpers if even possible.

pub fn server_side_encryption_customer_key(self, v: &str) -> S3Builder

Set server_side_encryption_customer_key for this backend.

§Args

v: base64 encoded key that matches algorithm specified in server_side_encryption_customer_algorithm.

§Note

This function is the low-level setting for SSE related features.

SSE related options should be set carefully to make them works. Please use server_side_encryption_with_* helpers if even possible.

pub fn server_side_encryption_customer_key_md5(self, v: &str) -> S3Builder

Set server_side_encryption_customer_key_md5 for this backend.

§Args

v: MD5 digest of key specified in server_side_encryption_customer_key.

§Note

This function is the low-level setting for SSE related features.

SSE related options should be set carefully to make them works. Please use server_side_encryption_with_* helpers if even possible.

pub fn server_side_encryption_with_aws_managed_kms_key(self) -> S3Builder

Enable server side encryption with aws managed kms key

As known as: SSE-KMS

NOTE: This function should not be used along with other server_side_encryption_with_ functions.

pub fn server_side_encryption_with_customer_managed_kms_key( self, aws_kms_key_id: &str, ) -> S3Builder

Enable server side encryption with customer managed kms key

As known as: SSE-KMS

NOTE: This function should not be used along with other server_side_encryption_with_ functions.

pub fn server_side_encryption_with_s3_key(self) -> S3Builder

Enable server side encryption with s3 managed key

As known as: SSE-S3

NOTE: This function should not be used along with other server_side_encryption_with_ functions.

pub fn server_side_encryption_with_customer_key( self, algorithm: &str, key: &[u8], ) -> S3Builder

Enable server side encryption with customer key.

As known as: SSE-C

NOTE: This function should not be used along with other server_side_encryption_with_ functions.

pub fn session_token(self, token: &str) -> S3Builder

Set temporary credential used in AWS S3 connections

§Warning

session token’s lifetime is short and requires users to refresh in time.

pub fn container_credentials_relative_uri(self, uri: &str) -> S3Builder

Set the relative URI for AWS container credential metadata.

An explicit full endpoint takes precedence. The relative URI takes precedence over ambient full and relative container credential URIs and is joined to Self::container_metadata_uri_override when set.

This setting configures the ECS slot in the default credential chain. It does not move that slot ahead of earlier default providers.

pub fn container_credentials_endpoint(self, endpoint: &str) -> S3Builder

Set the full URI for AWS container credential metadata.

This endpoint takes precedence over the relative URI and both ambient container credential URI forms.

pub fn container_authorization_token(self, token: &str) -> S3Builder

Set the authorization token for AWS container credential requests.

This value takes precedence over the configured token file and both ambient token forms.

pub fn container_authorization_token_file(self, file_path: &str) -> S3Builder

Set the file containing the authorization token for AWS container credential requests.

This file takes precedence over both ambient token forms. The credential provider trims surrounding whitespace after reading the file.

pub fn container_metadata_uri_override(self, uri: &str) -> S3Builder

Set the base URI used to resolve a relative AWS container credential URI.

The override affects relative URIs only and does not alter a configured or ambient full URI. The override alone does not select an endpoint.

pub fn disable_config_load(self) -> S3Builder

Disable automatic endpoint loading and ambient environment/profile credential providers.

This skips endpoint environment variables and removes the static environment, shared-profile, SSO, web-identity, and external process credential slots. Region environment lookup and compute metadata credential providers, including AWS container credentials and EC2 instance metadata, remain enabled.

pub fn disable_list_objects_v2(self) -> S3Builder

Disable list objects v2 so that opendal will fall back to the older List Objects V1 to list objects.

By default, OpenDAL uses List Objects V2 to list objects. However, some legacy services do not yet support V2.

pub fn enable_request_payer(self) -> S3Builder

Enable request payer so that OpenDAL will send requests with x-amz-request-payer header.

With this option the client accepts to pay for the request and data transfer costs.

pub fn disable_ec2_metadata(self) -> S3Builder

Disable load credential from ec2 metadata.

This option is used to disable the default behavior of opendal to load credential from ec2 metadata, a.k.a, IMDSv2

pub fn skip_signature(self) -> S3Builder

Skip signature will skip loading credentials and signing requests.

pub fn allow_anonymous(self) -> S3Builder

👎Deprecated since 0.57.0:

Please use skip_signature instead of allow_anonymous

Allow anonymous will allow opendal to send request without signing when credential is not loaded.

pub fn enable_virtual_host_style(self) -> S3Builder

Enable virtual host style so that opendal will send API requests in virtual host style instead of path style.

  • By default, opendal will send API to https://s3.us-east-1.amazonaws.com/bucket_name
  • Enabled, opendal will send API to https://bucket_name.s3.us-east-1.amazonaws.com

pub fn disable_stat_with_override(self) -> S3Builder

👎Deprecated since 0.57.0:

S3 stat override capabilities are enabled by default and this option is no longer needed.

Deprecated: S3 stat override capabilities are enabled by default.

pub fn enable_versioning(self, _enabled: bool) -> S3Builder

👎Deprecated since 0.57.0:

S3 versioning capability is enabled by default and this option is no longer needed.

Deprecated: S3 versioning capability is enabled by default.

pub fn credential_provider_chain( self, chain: ProvideCredentialChain<Credential>, ) -> S3Builder

Replace the credential providers with a custom chain.

Build the chain from opendal_core::reqsign_core and [crate::reqsign_aws_v4] so that its types match the ones this service is built with.

pub fn batch_max_operations(self, _batch_max_operations: usize) -> S3Builder

👎Deprecated since 0.57.0:

S3 delete batch capability is enabled by default and this option is no longer needed.

Deprecated: S3 delete batch capability is enabled by default.

pub fn delete_max_size(self, _delete_max_size: usize) -> S3Builder

👎Deprecated since 0.57.0:

S3 delete batch capability is enabled by default and this option is no longer needed.

Deprecated: S3 delete batch capability is enabled by default.

pub fn checksum_algorithm(self, checksum_algorithm: &str) -> S3Builder

Set checksum algorithm of this backend. This is necessary when writing to AWS S3 Buckets with Object Lock enabled for example.

Available options:

  • “crc32c”
  • “md5”

pub fn disable_write_with_if_match(self) -> S3Builder

👎Deprecated since 0.57.0:

S3 write with If-Match capability is enabled by default and this option is no longer needed.

Deprecated: S3 write with If-Match capability is enabled by default.

pub fn enable_write_with_append(self) -> S3Builder

👎Deprecated since 0.57.0:

S3 append capability is enabled by default and this option is no longer needed.

Deprecated: S3 append capability is enabled by default.

pub async fn detect_region(endpoint: &str, bucket: &str) -> Option<String>

Detect region of S3 bucket.

§Args
  • endpoint: the endpoint of S3 service
  • bucket: the bucket of S3 service
§Return
  • Some(region) means we detect the region successfully
  • None means we can’t detect the region or meeting errors.
§Notes

We will try to detect region by the following methods.

  • Match endpoint with given rules to get region
    • Cloudflare R2
    • AWS S3
    • Aliyun OSS
    • Neon Object Storage
  • Send a HEAD request to endpoint with bucket name to get x-amz-bucket-region.
§Examples
use opendal_service_s3::S3;

let region: Option<String> = S3::detect_region("https://s3.amazonaws.com", "example").await;
§Reference

pub fn default_acl(self, acl: &str) -> S3Builder

Set default ACL for new objects.

Trait Implementations§

§

impl Builder for S3Builder

§

type Config = S3Config

Associated configuration.
§

fn build(self) -> Result<impl Service, Error>

Consume the builder to build a service.
§

impl Debug for S3Builder

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl Default for S3Builder

§

fn default() -> S3Builder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Conv for T

§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
§

impl<T> DropFlavorWrapper<T> for T

§

type Flavor = MayDrop

The DropFlavor that [wrap]s T into Self
§

impl<T> FmtForward for T

§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self> ⓘ

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

§

const WITNESS: W = W::MAKE

A constant of the type witness
§

impl<T> Identity for T
where T: ?Sized,

§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
§

impl<T> MaybeSend for T
where T: Send,

§

impl<T> MaybeSend for T
where T: Send,

§

impl<T> Pipe for T
where T: ?Sized,

§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<E> ResultError for E
where E: Send + Debug + Sync,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T> Scope for T

§

fn with<F, R>(self, f: F) -> R
where Self: Sized, F: FnOnce(Self) -> R,

Scoped with ownership.
§

fn with_ref<F, R>(&self, f: F) -> R
where F: FnOnce(&Self) -> R,

Scoped with reference.
§

fn with_mut<F, R>(&mut self, f: F) -> R
where F: FnOnce(&mut Self) -> R,

Scoped with mutable reference.
§

impl<T> Tap for T

§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
§

impl<T> TryConv for T

§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> Value for T
where T: Send + Sync + 'static,

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

§

fn is_within(&self, b: &G2) -> bool