pub struct AsyncMultipartUpload<'a> { /* private fields */ }Expand description
A implementation of AsyncWrite for S3 objects using multipart uploads. By using multipart uploads constant memory usage can be achieved.
§Note
On failure the multipart upload is not aborted. It is up to the
caller to call the S3 abortMultipartUpload API when required.
use cobalt_aws::s3::{AsyncMultipartUpload, Client, S3Object};
use cobalt_aws::config::load_from_env;
use futures::AsyncWriteExt;
let shared_config = load_from_env().await.unwrap();
let client = Client::new(&shared_config);
let dst = S3Object::new("my-bucket", "my-key");
let part_size = 5 * 1_048_576;
let mut writer = AsyncMultipartUpload::new(&client, &dst, part_size, None).await.unwrap();
let buffer_len = 6 * 1_048_576;
// Each part is uploaded as it's available
writer.write_all(&vec![0; buffer_len]).await.unwrap();
// The pending parts are uploaded and the multipart upload is completed
// on close.
writer.close().await.unwrap();Implementations§
Source§impl<'a> AsyncMultipartUpload<'a>
impl<'a> AsyncMultipartUpload<'a>
Sourcepub async fn new(
client: &'a Client,
dst: &S3Object,
part_size: usize,
max_uploading_parts: Option<usize>,
) -> Result<AsyncMultipartUpload<'a>>
pub async fn new( client: &'a Client, dst: &S3Object, part_size: usize, max_uploading_parts: Option<usize>, ) -> Result<AsyncMultipartUpload<'a>>
Create a new AsyncMultipartUpload.
client- S3 client to use.dst- The S3Object to write the object into.part_size- How large, in bytes, each part should be. Must be larger than 5MIB and smaller that 5GIB.max_uploading_parts- How many parts to upload concurrently, Must be larger than 0 (defaults to 100).
Sourcepub async fn from(
client: &'a Client,
upload_id: String,
dst: &S3Object,
part_size: usize,
max_uploading_parts: Option<usize>,
) -> Result<AsyncMultipartUpload<'a>>
pub async fn from( client: &'a Client, upload_id: String, dst: &S3Object, part_size: usize, max_uploading_parts: Option<usize>, ) -> Result<AsyncMultipartUpload<'a>>
Import an existing AsyncMultipartUpload to continue uploading.
client- S3 client to use.upload_id- The multipart upload ID to resume.dst- The S3Object to write the object into.part_size- How large, in bytes, each part should be. Must be larger than 5MIB and smaller that 5GIB.max_uploading_parts- How many parts to upload concurrently, Must be larger than 0 (defaults to 100).
pub fn get_upload_id(&self) -> &str
Trait Implementations§
Source§impl<'a> AsyncWrite for AsyncMultipartUpload<'a>
impl<'a> AsyncWrite for AsyncMultipartUpload<'a>
Source§fn poll_write(
self: Pin<&mut AsyncMultipartUpload<'a>>,
cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<Result<usize, Error>>
fn poll_write( self: Pin<&mut AsyncMultipartUpload<'a>>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize, Error>>
Attempt to write bytes from
buf into the object. Read moreSource§fn poll_flush(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<(), Error>>
fn poll_flush( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Result<(), Error>>
Attempt to flush the object, ensuring that any buffered data reach
their destination. Read more
Auto Trait Implementations§
impl<'a> Freeze for AsyncMultipartUpload<'a>
impl<'a> !RefUnwindSafe for AsyncMultipartUpload<'a>
impl<'a> Send for AsyncMultipartUpload<'a>
impl<'a> !Sync for AsyncMultipartUpload<'a>
impl<'a> Unpin for AsyncMultipartUpload<'a>
impl<'a> !UnwindSafe for AsyncMultipartUpload<'a>
Blanket Implementations§
Source§impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
Source§fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
Convert the given value into an approximately equivalent representation.
Source§impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
Source§type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
The error type produced by a failed conversion.
Source§fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
Convert the subject into an approximately equivalent representation.
Source§impl<W> AsyncWriteExt for Wwhere
W: AsyncWrite + ?Sized,
impl<W> AsyncWriteExt for Wwhere
W: AsyncWrite + ?Sized,
Source§fn flush(&mut self) -> Flush<'_, Self>where
Self: Unpin,
fn flush(&mut self) -> Flush<'_, Self>where
Self: Unpin,
Creates a future which will entirely flush this
AsyncWrite. Read moreSource§fn close(&mut self) -> Close<'_, Self>where
Self: Unpin,
fn close(&mut self) -> Close<'_, Self>where
Self: Unpin,
Creates a future which will entirely close this
AsyncWrite.Source§fn write<'a>(&'a mut self, buf: &'a [u8]) -> Write<'a, Self>where
Self: Unpin,
fn write<'a>(&'a mut self, buf: &'a [u8]) -> Write<'a, Self>where
Self: Unpin,
Creates a future which will write bytes from
buf into the object. Read moreSource§fn write_vectored<'a>(
&'a mut self,
bufs: &'a [IoSlice<'a>],
) -> WriteVectored<'a, Self>where
Self: Unpin,
fn write_vectored<'a>(
&'a mut self,
bufs: &'a [IoSlice<'a>],
) -> WriteVectored<'a, Self>where
Self: Unpin,
Creates a future which will write bytes from
bufs into the object using vectored
IO operations. Read moreSource§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
Mutably borrows from an owned value. Read more
Source§impl<T, Dst> ConvAsUtil<Dst> for T
impl<T, Dst> ConvAsUtil<Dst> for T
Source§impl<T> ConvUtil for T
impl<T> ConvUtil for T
Source§fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
Approximate the subject to a given type with the default scheme.
Source§fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
Approximate the subject to a given type with a specific scheme.
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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>
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 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>
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 moreCreates a shared type from an unshared type.