pub struct Bucket {
    pub name: String,
    pub region: Region,
    pub credentials: Arc<RwLock<Credentials>>,
    pub extra_headers: HeaderMap,
    pub extra_query: Query,
    pub request_timeout: Option<Duration>,
    /* private fields */
}
Expand description

Instantiate an existing Bucket

Example

use s3::bucket::Bucket;
use s3::creds::Credentials;

let bucket_name = "rust-s3-test";
let region = "us-east-1".parse().unwrap();
let credentials = Credentials::default().unwrap();

let bucket = Bucket::new(bucket_name, region, credentials);

Fields

name: Stringregion: Regioncredentials: Arc<RwLock<Credentials>>extra_headers: HeaderMapextra_query: Queryrequest_timeout: Option<Duration>

Implementations

Get a presigned url for getting object on a given path

Example:
use std::collections::HashMap;
use s3::bucket::Bucket;
use s3::creds::Credentials;

let bucket_name = "rust-s3-test";
let region = "us-east-1".parse().unwrap();
let credentials = Credentials::default().unwrap();
let bucket = Bucket::new(bucket_name, region, credentials).unwrap();

// Add optional custom queries
let mut custom_queries = HashMap::new();
custom_queries.insert(
   "response-content-disposition".into(),
   "attachment; filename=\"test.png\"".into(),
);

let url = bucket.presign_get("/test.file", 86400, Some(custom_queries)).unwrap();
println!("Presigned url: {}", url);
source

pub fn presign_post<S: AsRef<str>>(
    &self,
    path: S,
    expiry_secs: u32,
    post_policy: String
) -> Result<String, S3Error>

Get a presigned url for posting an object to a given path

Example:
use s3::bucket::Bucket;
use s3::creds::Credentials;
use http::HeaderMap;
use http::header::HeaderName;

let bucket_name = "rust-s3-test";
let region = "us-east-1".parse().unwrap();
let credentials = Credentials::default().unwrap();
let bucket = Bucket::new(bucket_name, region, credentials).unwrap();

let post_policy = "eyAiZXhwaXJhdGlvbiI6ICIyMDE1LTEyLTMwVDEyOjAwOjAwLjAwMFoiLA0KICAiY29uZGl0aW9ucyI6IFsNCiAgICB7ImJ1Y2tldCI6ICJzaWd2NGV4YW1wbGVidWNrZXQifSwNCiAgICBbInN0YXJ0cy13aXRoIiwgIiRrZXkiLCAidXNlci91c2VyMS8iXSwNCiAgICB7ImFjbCI6ICJwdWJsaWMtcmVhZCJ9LA0KICAgIHsic3VjY2Vzc19hY3Rpb25fcmVkaXJlY3QiOiAiaHR0cDovL3NpZ3Y0ZXhhbXBsZWJ1Y2tldC5zMy5hbWF6b25hd3MuY29tL3N1Y2Nlc3NmdWxfdXBsb2FkLmh0bWwifSwNCiAgICBbInN0YXJ0cy13aXRoIiwgIiRDb250ZW50LVR5cGUiLCAiaW1hZ2UvIl0sDQogICAgeyJ4LWFtei1tZXRhLXV1aWQiOiAiMTQzNjUxMjM2NTEyNzQifSwNCiAgICB7IngtYW16LXNlcnZlci1zaWRlLWVuY3J5cHRpb24iOiAiQUVTMjU2In0sDQogICAgWyJzdGFydHMtd2l0aCIsICIkeC1hbXotbWV0YS10YWciLCAiIl0sDQoNCiAgICB7IngtYW16LWNyZWRlbnRpYWwiOiAiQUtJQUlPU0ZPRE5ON0VYQU1QTEUvMjAxNTEyMjkvdXMtZWFzdC0xL3MzL2F3czRfcmVxdWVzdCJ9LA0KICAgIHsieC1hbXotYWxnb3JpdGhtIjogIkFXUzQtSE1BQy1TSEEyNTYifSwNCiAgICB7IngtYW16LWRhdGUiOiAiMjAxNTEyMjlUMDAwMDAwWiIgfQ0KICBdDQp9";

let url = bucket.presign_post("/test.file", 86400, post_policy.to_string()).unwrap();
println!("Presigned url: {}", url);

Get a presigned url for putting object to a given path

Example:
use s3::bucket::Bucket;
use s3::creds::Credentials;
use http::HeaderMap;
use http::header::HeaderName;

let bucket_name = "rust-s3-test";
let region = "us-east-1".parse().unwrap();
let credentials = Credentials::default().unwrap();
let bucket = Bucket::new(bucket_name, region, credentials).unwrap();

// Add optional custom headers
let mut custom_headers = HeaderMap::new();
custom_headers.insert(
   HeaderName::from_static("custom_header"),
   "custom_value".parse().unwrap(),
);

let url = bucket.presign_put("/test.file", 86400, Some(custom_headers)).unwrap();
println!("Presigned url: {}", url);

Get a presigned url for deleting object on a given path

Example:
use s3::bucket::Bucket;
use s3::creds::Credentials;

let bucket_name = "rust-s3-test";
let region = "us-east-1".parse().unwrap();
let credentials = Credentials::default().unwrap();
let bucket = Bucket::new(bucket_name, region, credentials).unwrap();

let url = bucket.presign_delete("/test.file", 86400).unwrap();
println!("Presigned url: {}", url);

Create a new Bucket and instantiate it

use s3::{Bucket, BucketConfiguration};
use s3::creds::Credentials;
use anyhow::Result;

let bucket_name = "rust-s3-test";
let region = "us-east-1".parse()?;
let credentials = Credentials::default()?;
let config = BucketConfiguration::default();

// Async variant with `tokio` or `async-std` features
let create_bucket_response = Bucket::create(bucket_name, region, credentials, config).await?;

// `sync` fature will produce an identical method
#[cfg(feature = "sync")]
let create_bucket_response = Bucket::create(bucket_name, region, credentials, config)?;

// Blocking variant, generated with `blocking` feature in combination
// with `tokio` or `async-std` features.
#[cfg(feature = "blocking")]
let create_bucket_response = Bucket::create_blocking(bucket_name, region, credentials, config)?;

Create a new Bucket with path style and instantiate it

use s3::{Bucket, BucketConfiguration};
use s3::creds::Credentials;
use anyhow::Result;

let bucket_name = "rust-s3-test";
let region = "us-east-1".parse()?;
let credentials = Credentials::default()?;
let config = BucketConfiguration::default();

// Async variant with `tokio` or `async-std` features
let create_bucket_response = Bucket::create_with_path_style(bucket_name, region, credentials, config).await?;

// `sync` fature will produce an identical method
#[cfg(feature = "sync")]
let create_bucket_response = Bucket::create_with_path_style(bucket_name, region, credentials, config)?;

// Blocking variant, generated with `blocking` feature in combination
// with `tokio` or `async-std` features.
#[cfg(feature = "blocking")]
let create_bucket_response = Bucket::create_with_path_style_blocking(bucket_name, region, credentials, config)?;

Delete existing Bucket

Example
use s3::Bucket;
use s3::creds::Credentials;
use anyhow::Result;

let bucket_name = "rust-s3-test";
let region = "us-east-1".parse().unwrap();
let credentials = Credentials::default().unwrap();
let bucket = Bucket::new(bucket_name, region, credentials).unwrap();

// Async variant with `tokio` or `async-std` features
bucket.delete().await.unwrap();
// `sync` fature will produce an identical method

#[cfg(feature = "sync")]
bucket.delete().unwrap();
// Blocking variant, generated with `blocking` feature in combination
// with `tokio` or `async-std` features.

#[cfg(feature = "blocking")]
bucket.delete_blocking().unwrap();

Instantiate an existing Bucket.

Example
use s3::bucket::Bucket;
use s3::creds::Credentials;

// Fake  credentials so we don't access user's real credentials in tests
let bucket_name = "rust-s3-test";
let region = "us-east-1".parse().unwrap();
let credentials = Credentials::default().unwrap();

let bucket = Bucket::new(bucket_name, region, credentials).unwrap();

Instantiate a public existing Bucket.

Example
use s3::bucket::Bucket;

let bucket_name = "rust-s3-test";
let region = "us-east-1".parse().unwrap();

let bucket = Bucket::new_public(bucket_name, region).unwrap();

Copy file from an S3 path, internally within the same bucket.

Example:
use s3::bucket::Bucket;
use s3::creds::Credentials;
use anyhow::Result;


let bucket_name = "rust-s3-test";
let region = "us-east-1".parse()?;
let credentials = Credentials::default()?;
let bucket = Bucket::new(bucket_name, region, credentials)?;

// Async variant with `tokio` or `async-std` features
let code = bucket.copy_object_internal("/from.file", "/to.file").await?;

// `sync` feature will produce an identical method
#[cfg(feature = "sync")]
let code = bucket.copy_object_internal("/from.file", "/to.file")?;

Gets file from an S3 path.

Example:
use s3::bucket::Bucket;
use s3::creds::Credentials;
use anyhow::Result;


let bucket_name = "rust-s3-test";
let region = "us-east-1".parse()?;
let credentials = Credentials::default()?;
let bucket = Bucket::new(bucket_name, region, credentials)?;

// Async variant with `tokio` or `async-std` features
let response_data = bucket.get_object("/test.file").await?;

// `sync` feature will produce an identical method
#[cfg(feature = "sync")]
let response_data = bucket.get_object("/test.file")?;

// Blocking variant, generated with `blocking` feature in combination
// with `tokio` or `async-std` features.
#[cfg(feature = "blocking")]
let response_data = bucket.get_object_blocking("/test.file")?;

Gets torrent from an S3 path.

Example:
use s3::bucket::Bucket;
use s3::creds::Credentials;
use anyhow::Result;


let bucket_name = "rust-s3-test";
let region = "us-east-1".parse()?;
let credentials = Credentials::default()?;
let bucket = Bucket::new(bucket_name, region, credentials)?;

// Async variant with `tokio` or `async-std` features
let response_data = bucket.get_object_torrent("/test.file").await?;

// `sync` feature will produce an identical method
#[cfg(feature = "sync")]
let response_data = bucket.get_object_torrent("/test.file")?;

// Blocking variant, generated with `blocking` feature in combination
// with `tokio` or `async-std` features.
#[cfg(feature = "blocking")]
let response_data = bucket.get_object_torrent_blocking("/test.file")?;

Gets specified inclusive byte range of file from an S3 path.

Example:
use s3::bucket::Bucket;
use s3::creds::Credentials;
use anyhow::Result;


let bucket_name = "rust-s3-test";
let region = "us-east-1".parse()?;
let credentials = Credentials::default()?;
let bucket = Bucket::new(bucket_name, region, credentials)?;

// Async variant with `tokio` or `async-std` features
let response_data = bucket.get_object_range("/test.file", 0, Some(31)).await?;

// `sync` feature will produce an identical method
#[cfg(feature = "sync")]
let response_data = bucket.get_object_range("/test.file", 0, Some(31))?;

// Blocking variant, generated with `blocking` feature in combination
// with `tokio` or `async-std` features.
#[cfg(feature = "blocking")]
let response_data = bucket.get_object_range_blocking("/test.file", 0, Some(31))?;

Stream range of bytes from S3 path to a local file, generic over T: Write.

Example:
use s3::bucket::Bucket;
use s3::creds::Credentials;
use anyhow::Result;
use std::fs::File;


let bucket_name = "rust-s3-test";
let region = "us-east-1".parse()?;
let credentials = Credentials::default()?;
let bucket = Bucket::new(bucket_name, region, credentials)?;
let mut output_file = File::create("output_file").expect("Unable to create file");
let mut async_output_file = tokio::fs::File::create("async_output_file").await.expect("Unable to create file");
#[cfg(feature = "with-async-std")]
let mut async_output_file = async_std::fs::File::create("async_output_file").await.expect("Unable to create file");

let start = 0;
let end = Some(1024);

// Async variant with `tokio` or `async-std` features
let status_code = bucket.get_object_range_to_writer("/test.file", start, end, &mut async_output_file).await?;

// `sync` feature will produce an identical method
#[cfg(feature = "sync")]
let status_code = bucket.get_object_range_to_writer("/test.file", start, end, &mut output_file)?;

// Blocking variant, generated with `blocking` feature in combination
// with `tokio` or `async-std` features. Based of the async branch
#[cfg(feature = "blocking")]
let status_code = bucket.get_object_range_to_writer_blocking("/test.file", start, end, &mut async_output_file)?;

Stream file from S3 path to a local file, generic over T: Write.

Example:
use s3::bucket::Bucket;
use s3::creds::Credentials;
use anyhow::Result;
use std::fs::File;


let bucket_name = "rust-s3-test";
let region = "us-east-1".parse()?;
let credentials = Credentials::default()?;
let bucket = Bucket::new(bucket_name, region, credentials)?;
let mut output_file = File::create("output_file").expect("Unable to create file");
let mut async_output_file = tokio::fs::File::create("async_output_file").await.expect("Unable to create file");
#[cfg(feature = "with-async-std")]
let mut async_output_file = async_std::fs::File::create("async_output_file").await.expect("Unable to create file");

// Async variant with `tokio` or `async-std` features
let status_code = bucket.get_object_to_writer("/test.file", &mut async_output_file).await?;

// `sync` feature will produce an identical method
#[cfg(feature = "sync")]
let status_code = bucket.get_object_to_writer("/test.file", &mut output_file)?;

// Blocking variant, generated with `blocking` feature in combination
// with `tokio` or `async-std` features. Based of the async branch
#[cfg(feature = "blocking")]
let status_code = bucket.get_object_to_writer_blocking("/test.file", &mut async_output_file)?;

Stream file from S3 path to a local file using an async stream.

Example
use s3::bucket::Bucket;
use s3::creds::Credentials;
use anyhow::Result;
#[cfg(feature = "with-tokio")]
use tokio_stream::StreamExt;
#[cfg(feature = "with-tokio")]
use tokio::io::AsyncWriteExt;
#[cfg(feature = "with-async-std")]
use futures_util::StreamExt;
#[cfg(feature = "with-async-std")]
use futures_util::AsyncWriteExt;


let bucket_name = "rust-s3-test";
let region = "us-east-1".parse()?;
let credentials = Credentials::default()?;
let bucket = Bucket::new(bucket_name, region, credentials)?;
let path = "path";

let mut response_data_stream = bucket.get_object_stream(path).await?;

#[cfg(feature = "with-tokio")]
let mut async_output_file = tokio::fs::File::create("async_output_file").await.expect("Unable to create file");
#[cfg(feature = "with-async-std")]
let mut async_output_file = async_std::fs::File::create("async_output_file").await.expect("Unable to create file");

while let Some(chunk) = response_data_stream.bytes().next().await {
    async_output_file.write_all(&chunk).await?;
}

Stream file from local path to s3, generic over T: Write.

Example:
use s3::bucket::Bucket;
use s3::creds::Credentials;
use anyhow::Result;
use std::fs::File;
use std::io::Write;


let bucket_name = "rust-s3-test";
let region = "us-east-1".parse()?;
let credentials = Credentials::default()?;
let bucket = Bucket::new(bucket_name, region, credentials)?;
let path = "path";
let test: Vec<u8> = (0..1000).map(|_| 42).collect();
let mut file = File::create(path)?;
file.write_all(&test)?;

// Generic over std::io::Read
let status_code = bucket.put_object_stream(&mut file, "/path").await?;

// `sync` feature will produce an identical method
#[cfg(feature = "sync")]
// Generic over std::io::Read
let status_code = bucket.put_object_stream(&mut path, "/path")?;

// Blocking variant, generated with `blocking` feature in combination
// with `tokio` or `async-std` features.
#[cfg(feature = "blocking")]
let status_code = bucket.put_object_stream_blocking(&mut path, "/path")?;

Stream file from local path to s3, generic over T: Write with explicit content type.

Example:
use s3::bucket::Bucket;
use s3::creds::Credentials;
use anyhow::Result;
use std::fs::File;
use std::io::Write;


let bucket_name = "rust-s3-test";
let region = "us-east-1".parse()?;
let credentials = Credentials::default()?;
let bucket = Bucket::new(bucket_name, region, credentials)?;
let path = "path";
let test: Vec<u8> = (0..1000).map(|_| 42).collect();
let mut file = File::create(path)?;
file.write_all(&test)?;

// Async variant with `tokio` or `async-std` features
// Generic over std::io::Read
let status_code = bucket
    .put_object_stream_with_content_type(&mut file, "/path", "application/octet-stream")
    .await?;

// `sync` feature will produce an identical method
#[cfg(feature = "sync")]
// Generic over std::io::Read
let status_code = bucket
    .put_object_stream_with_content_type(&mut path, "/path", "application/octet-stream")?;

// Blocking variant, generated with `blocking` feature in combination
// with `tokio` or `async-std` features.
#[cfg(feature = "blocking")]
let status_code = bucket
    .put_object_stream_with_content_type_blocking(&mut path, "/path", "application/octet-stream")?;

Initiate multipart upload to s3.

Upload a streamed multipart chunk to s3 using a previously initiated multipart upload

Upload a buffered multipart chunk to s3 using a previously initiated multipart upload

Completes a previously initiated multipart upload, with optional final data chunks

Get Bucket location.

Example:
use s3::bucket::Bucket;
use s3::creds::Credentials;
use anyhow::Result;


let bucket_name = "rust-s3-test";
let region = "us-east-1".parse()?;
let credentials = Credentials::default()?;
let bucket = Bucket::new(bucket_name, region, credentials)?;

// Async variant with `tokio` or `async-std` features
let (region, status_code) = bucket.location().await?;

// `sync` feature will produce an identical method
#[cfg(feature = "sync")]
let (region, status_code) = bucket.location()?;

// Blocking variant, generated with `blocking` feature in combination
// with `tokio` or `async-std` features.
#[cfg(feature = "blocking")]
let (region, status_code) = bucket.location_blocking()?;

Delete file from an S3 path.

Example:
use s3::bucket::Bucket;
use s3::creds::Credentials;
use anyhow::Result;


let bucket_name = "rust-s3-test";
let region = "us-east-1".parse()?;
let credentials = Credentials::default()?;
let bucket = Bucket::new(bucket_name, region, credentials)?;

// Async variant with `tokio` or `async-std` features
let response_data = bucket.delete_object("/test.file").await?;

// `sync` feature will produce an identical method
#[cfg(feature = "sync")]
let response_data = bucket.delete_object("/test.file")?;

// Blocking variant, generated with `blocking` feature in combination
// with `tokio` or `async-std` features.
#[cfg(feature = "blocking")]
let response_data = bucket.delete_object_blocking("/test.file")?;

Head object from S3.

Example:
use s3::bucket::Bucket;
use s3::creds::Credentials;
use anyhow::Result;


let bucket_name = "rust-s3-test";
let region = "us-east-1".parse()?;
let credentials = Credentials::default()?;
let bucket = Bucket::new(bucket_name, region, credentials)?;

// Async variant with `tokio` or `async-std` features
let (head_object_result, code) = bucket.head_object("/test.png").await?;

// `sync` feature will produce an identical method
#[cfg(feature = "sync")]
let (head_object_result, code) = bucket.head_object("/test.png")?;

// Blocking variant, generated with `blocking` feature in combination
// with `tokio` or `async-std` features.
#[cfg(feature = "blocking")]
let (head_object_result, code) = bucket.head_object_blocking("/test.png")?;

Put into an S3 bucket, with explicit content-type.

Example:
use s3::bucket::Bucket;
use s3::creds::Credentials;
use anyhow::Result;


let bucket_name = "rust-s3-test";
let region = "us-east-1".parse()?;
let credentials = Credentials::default()?;
let bucket = Bucket::new(bucket_name, region, credentials)?;
let content = "I want to go to S3".as_bytes();

// Async variant with `tokio` or `async-std` features
let response_data = bucket.put_object_with_content_type("/test.file", content, "text/plain").await?;

// `sync` feature will produce an identical method
#[cfg(feature = "sync")]
let response_data = bucket.put_object_with_content_type("/test.file", content, "text/plain")?;

// Blocking variant, generated with `blocking` feature in combination
// with `tokio` or `async-std` features.
#[cfg(feature = "blocking")]
let response_data = bucket.put_object_with_content_type_blocking("/test.file", content, "text/plain")?;

Put into an S3 bucket.

Example:
use s3::bucket::Bucket;
use s3::creds::Credentials;
use anyhow::Result;


let bucket_name = "rust-s3-test";
let region = "us-east-1".parse()?;
let credentials = Credentials::default()?;
let bucket = Bucket::new(bucket_name, region, credentials)?;
let content = "I want to go to S3".as_bytes();

// Async variant with `tokio` or `async-std` features
let response_data = bucket.put_object("/test.file", content).await?;

// `sync` feature will produce an identical method
#[cfg(feature = "sync")]
let response_data = bucket.put_object("/test.file", content)?;

// Blocking variant, generated with `blocking` feature in combination
// with `tokio` or `async-std` features.
#[cfg(feature = "blocking")]
let response_data = bucket.put_object_blocking("/test.file", content)?;

Tag an S3 object.

Example:
use s3::bucket::Bucket;
use s3::creds::Credentials;
use anyhow::Result;


let bucket_name = "rust-s3-test";
let region = "us-east-1".parse()?;
let credentials = Credentials::default()?;
let bucket = Bucket::new(bucket_name, region, credentials)?;

// Async variant with `tokio` or `async-std` features
let response_data = bucket.put_object_tagging("/test.file", &[("Tag1", "Value1"), ("Tag2", "Value2")]).await?;

// `sync` feature will produce an identical method
#[cfg(feature = "sync")]
let response_data = bucket.put_object_tagging("/test.file", &[("Tag1", "Value1"), ("Tag2", "Value2")])?;

// Blocking variant, generated with `blocking` feature in combination
// with `tokio` or `async-std` features.
#[cfg(feature = "blocking")]
let response_data = bucket.put_object_tagging_blocking("/test.file", &[("Tag1", "Value1"), ("Tag2", "Value2")])?;

Delete tags from an S3 object.

Example:
use s3::bucket::Bucket;
use s3::creds::Credentials;
use anyhow::Result;


let bucket_name = "rust-s3-test";
let region = "us-east-1".parse()?;
let credentials = Credentials::default()?;
let bucket = Bucket::new(bucket_name, region, credentials)?;

// Async variant with `tokio` or `async-std` features
let response_data = bucket.delete_object_tagging("/test.file").await?;

// `sync` feature will produce an identical method
#[cfg(feature = "sync")]
let response_data = bucket.delete_object_tagging("/test.file")?;

// Blocking variant, generated with `blocking` feature in combination
// with `tokio` or `async-std` features.
#[cfg(feature = "blocking")]
let response_data = bucket.delete_object_tagging_blocking("/test.file")?;

Retrieve an S3 object list of tags.

Example:
use s3::bucket::Bucket;
use s3::creds::Credentials;
use anyhow::Result;


let bucket_name = "rust-s3-test";
let region = "us-east-1".parse()?;
let credentials = Credentials::default()?;
let bucket = Bucket::new(bucket_name, region, credentials)?;

// Async variant with `tokio` or `async-std` features
let response_data = bucket.get_object_tagging("/test.file").await?;

// `sync` feature will produce an identical method
#[cfg(feature = "sync")]
let response_data = bucket.get_object_tagging("/test.file")?;

// Blocking variant, generated with `blocking` feature in combination
// with `tokio` or `async-std` features.
#[cfg(feature = "blocking")]
let response_data = bucket.get_object_tagging_blocking("/test.file")?;

List the contents of an S3 bucket.

Example:
use s3::bucket::Bucket;
use s3::creds::Credentials;
use anyhow::Result;


let bucket_name = "rust-s3-test";
let region = "us-east-1".parse()?;
let credentials = Credentials::default()?;
let bucket = Bucket::new(bucket_name, region, credentials)?;

// Async variant with `tokio` or `async-std` features
let results = bucket.list("/".to_string(), Some("/".to_string())).await?;

// `sync` feature will produce an identical method
#[cfg(feature = "sync")]
let results = bucket.list("/".to_string(), Some("/".to_string()))?;

// Blocking variant, generated with `blocking` feature in combination
// with `tokio` or `async-std` features.
#[cfg(feature = "blocking")]
let results = bucket.list_blocking("/".to_string(), Some("/".to_string()))?;

List the ongoing multipart uploads of an S3 bucket. This may be useful to cleanup failed uploads, together with crate::bucket::Bucket::abort_upload.

Example:
use s3::bucket::Bucket;
use s3::creds::Credentials;
use anyhow::Result;


let bucket_name = "rust-s3-test";
let region = "us-east-1".parse()?;
let credentials = Credentials::default()?;
let bucket = Bucket::new(bucket_name, region, credentials)?;

// Async variant with `tokio` or `async-std` features
let results = bucket.list_multiparts_uploads(Some("/"), Some("/")).await?;

// `sync` feature will produce an identical method
#[cfg(feature = "sync")]
let results = bucket.list_multiparts_uploads(Some("/"), Some("/"))?;

// Blocking variant, generated with `blocking` feature in combination
// with `tokio` or `async-std` features.
#[cfg(feature = "blocking")]
let results = bucket.list_multiparts_uploads_blocking(Some("/"), Some("/"))?;

Abort a running multipart upload.

Example:
use s3::bucket::Bucket;
use s3::creds::Credentials;
use anyhow::Result;


let bucket_name = "rust-s3-test";
let region = "us-east-1".parse()?;
let credentials = Credentials::default()?;
let bucket = Bucket::new(bucket_name, region, credentials)?;

// Async variant with `tokio` or `async-std` features
let results = bucket.abort_upload("/some/file.txt", "ZDFjM2I0YmEtMzU3ZC00OTQ1LTlkNGUtMTgxZThjYzIwNjA2").await?;

// `sync` feature will produce an identical method
#[cfg(feature = "sync")]
let results = bucket.abort_upload("/some/file.txt", "ZDFjM2I0YmEtMzU3ZC00OTQ1LTlkNGUtMTgxZThjYzIwNjA2")?;

// Blocking variant, generated with `blocking` feature in combination
// with `tokio` or `async-std` features.
#[cfg(feature = "blocking")]
let results = bucket.abort_upload_blocking("/some/file.txt", "ZDFjM2I0YmEtMzU3ZC00OTQ1LTlkNGUtMTgxZThjYzIwNjA2")?;

Get path_style field of the Bucket struct

Get negated path_style field of the Bucket struct

Configure bucket to use path-style urls and headers

Configure bucket to use subdomain style urls and headers [default]

Configure bucket to apply this request timeout to all HTTP requests, or no (infinity) timeout if None. Defaults to 30 seconds.

Only the attohttpc and the Reqwest backends obey this option; async code may instead await with a timeout.

Configure bucket to use the older ListObjects API

If your provider doesn’t support the ListObjectsV2 interface, set this to use the v1 ListObjects interface instead. This is currently needed at least for Google Cloud Storage.

Configure bucket to use the newer ListObjectsV2 API

Get a reference to the name of the S3 bucket.

Get a paths-style reference to the hostname of the S3 API endpoint.

Get the region this object will connect to.

Get a reference to the AWS access key.

Get a reference to the AWS secret key.

Get a reference to the AWS security token.

Get a reference to the AWS session token.

Get a reference to the full Credentials object used by this Bucket.

Change the credentials used by the Bucket.

Add an extra header to send with requests to S3.

Add an extra header to send with requests. Note that the library already sets a number of headers - headers set with this method will be overridden by the library headers:

  • Host
  • Content-Type
  • Date
  • Content-Length
  • Authorization
  • X-Amz-Content-Sha256
  • X-Amz-Date

Get a reference to the extra headers to be passed to the S3 API.

Get a mutable reference to the extra headers to be passed to the S3 API.

Add an extra query pair to the URL used for S3 API access.

Get a reference to the extra query pairs to be passed to the S3 API.

Get a mutable reference to the extra query pairs to be passed to the S3 API.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

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

Calls U::from(self).

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

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more