Struct S3
pub struct S3 { /* private fields */ }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:
container_credentials_endpointcontainer_credentials_relative_uriAWS_CONTAINER_CREDENTIALS_FULL_URIAWS_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:
container_authorization_tokencontainer_authorization_token_fileAWS_CONTAINER_AUTHORIZATION_TOKENAWS_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
ListObjectsV2with/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. Leavedisable_list_objects_v2unset. Directory buckets do not supportstart_afteror guarantee lexicographical order. See the AWSListObjectsV2API 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 AWSPutBucketVersioningAPI reference. - Writes. OpenDAL supports conditional writes with
If-MatchandIf-None-Match: *, as well as appending to objects in theEXPRESS_ONEZONEstorage class. The service does not advertisewrite_with_content_encodingfor directory buckets. See the AWSPutObjectAPI 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::R2or ther2scheme for Cloudflare R2. - Use
crate::Minioor theminioscheme for MinIO deployments. - Use
crate::Akamaior theakamaischeme for Akamai Cloud Object Storage. - Use
crate::CephRgwor theceph-rgwscheme for Ceph RADOS Gateway. - Use
crate::Exoscaleor theexoscalescheme for Exoscale Simple Object Storage. - Use
crate::Garageor thegaragescheme for Garage deployments. - Use
crate::Hetzneror thehetznerscheme for Hetzner Object Storage. - Use
crate::IbmCosor theibm-cosscheme for IBM Cloud Object Storage. - Use
crate::IdriveE2or theidrive-e2scheme for IDrive e2. - Use
crate::Ionosor theionosscheme for IONOS Cloud Object Storage. - Use
crate::Neonor theneonscheme for Neon Object Storage. - Use
crate::Ocior theocischeme for Oracle Cloud Infrastructure Object Storage. - Use
crate::Ovhcloudor theovhcloudscheme for OVHcloud Object Storage. - Use
crate::Qingstoror theqingstorscheme for QingStor Object Storage. - Use
crate::Rustfsor therustfsscheme for RustFS deployments. - Use
crate::Scalewayor thescalewayscheme for Scaleway Object Storage. - Use
crate::Seaweedfsor theseaweedfsscheme for SeaweedFS S3 gateways. - Use
crate::Spacesor thespacesscheme for DigitalOcean Spaces. - Use
crate::Storjor thestorjscheme for the Storj-hosted S3 Gateway. - Use
crate::Supabaseor thesupabasescheme for Supabase Storage. - Use
crate::Tigrisor thetigrisscheme for Tigris. - Use
crate::Wasabior thewasabischeme 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::B2S3or theb2-s3scheme for Backblaze B2. - Use
crate::CosS3or thecos-s3scheme for Tencent Cloud COS. - Use
crate::GcsS3or thegcs-s3scheme for Google Cloud Storage. - Use
crate::LakefsS3or thelakefs-s3scheme for the lakeFS S3 Gateway. - Use
crate::ObsS3or theobs-s3scheme for Huawei Cloud OBS in the China public cloud. - Use
crate::OssS3or theoss-s3scheme for Alibaba Cloud OSS. - Use
crate::SwiftS3apior theswift-s3apischeme for OpenStack Swift s3api. - Use
crate::TosS3or thetos-s3scheme 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
impl S3Builder
pub fn root(self, root: &str) -> S3Builder
pub fn root(self, root: &str) -> S3Builder
Set root of this backend.
All operations will happen under this root.
pub fn endpoint(self, endpoint: &str) -> S3Builder
pub fn endpoint(self, endpoint: &str) -> S3Builder
Set endpoint of this backend.
Endpoint must be full uri, e.g.
- AWS S3:
https://s3.amazonaws.comorhttps://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
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
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
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
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
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
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
pub fn external_id(self, v: &str) -> S3Builder
Set external_id for this backend.
pub fn role_session_name(self, v: &str) -> S3Builder
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
pub fn assume_role_duration_seconds(self, v: u32) -> S3Builder
Set assume_role_duration_seconds for this backend.
Set assume_role_session_tags for this backend.
pub fn default_storage_class(self, v: &str) -> S3Builder
pub fn default_storage_class(self, v: &str) -> S3Builder
Set default storage_class for this backend.
Available values:
DEEP_ARCHIVEGLACIERGLACIER_IRINTELLIGENT_TIERINGONEZONE_IAOUTPOSTSREDUCED_REDUNDANCYSTANDARDSTANDARD_IA
pub fn server_side_encryption(self, v: &str) -> S3Builder
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
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_encryptionset toaws:kms, andserver_side_encryption_aws_kms_key_idis not set, S3 will use aws managed kms key to encrypt data. - If
server_side_encryptionset toaws:kms, andserver_side_encryption_aws_kms_key_idis a valid kms key id, S3 will use the provided kms key to encrypt data. - If the
server_side_encryption_aws_kms_key_idis invalid or not found, an error will be returned. - If
server_side_encryptionis notaws:kms, settingserver_side_encryption_aws_kms_key_idis 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
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
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
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
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
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
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
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
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
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
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
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.
Set the authorization token for AWS container credential requests.
This value takes precedence over the configured token file and both ambient token forms.
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
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
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
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
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
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
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
pub fn allow_anonymous(self) -> S3Builder
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
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.
pub fn disable_stat_with_override(self) -> S3Builder
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.
pub fn enable_versioning(self, _enabled: bool) -> S3Builder
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
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.
pub fn batch_max_operations(self, _batch_max_operations: usize) -> S3Builder
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.
pub fn delete_max_size(self, _delete_max_size: usize) -> S3Builder
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
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.
pub fn disable_write_with_if_match(self) -> S3Builder
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.
pub fn enable_write_with_append(self) -> S3Builder
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>
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 successfullyNonemeans 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
HEADrequest to endpoint with bucket name to getx-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
pub fn default_acl(self, acl: &str) -> S3Builder
Set default ACL for new objects.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for S3Builder
impl !UnwindSafe for S3Builder
impl Freeze for S3Builder
impl Send for S3Builder
impl Sync for S3Builder
impl Unpin for S3Builder
impl UnsafeUnpin for S3Builder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].impl<T> MaybeSend for Twhere
T: Send,
impl<T> MaybeSend for Twhere
T: Send,
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
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) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
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
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
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
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
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
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<E> ResultError for E
§impl<T> Scope for T
impl<T> Scope for T
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.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
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.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
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.