use aws_sdk_s3::Client;
use log_derive::logfn;
use crate::{
download,
errors::{Error, Result},
opts::*,
upload, S3PathParam,
};
#[logfn(err = "ERROR")]
pub async fn copy(
s3: &Client,
source: S3PathParam,
destination: S3PathParam,
opts: AwsCopyOptParams,
) -> Result<()> {
match source {
S3PathParam::Bucket { bucket, key } => match destination {
S3PathParam::Local { path } => download(s3, bucket, key, path, opts.into()).await,
S3PathParam::Bucket { bucket: _, key: _ } => {
Err(Error::BucketToBucketCpNotImplementedError)
}
},
S3PathParam::Local { path } => match destination {
S3PathParam::Bucket { bucket, key } => upload(s3, bucket, key, path, opts.into()).await,
S3PathParam::Local { path: _ } => Err(Error::LocalToLocalCpNotImplementedError),
},
}
}