use aws_sdk_s3::{ error::SdkError, operation::put_object::PutObjectError, primitives::ByteStream, Client, }; use uuid::Uuid; pub async fn init_aws_client() -> Client { dotenvy::dotenv().expect("Failed loading env"); let config = aws_config::load_from_env().await; Client::new(&config) } pub async fn upload_image( client: &Client, realtor_id: Uuid, file_name: String, multipart: Vec, ) -> Result> { let path = format!("realtor-images/{realtor_id}/{file_name}"); match client .put_object() .bucket("realtor-lp-bucket") .key(path.clone()) .body(ByteStream::from(multipart)) .acl(aws_sdk_s3::types::ObjectCannedAcl::PublicRead) .send() .await { Ok(_) => Ok(format!( "https://realtor-lp-bucket.s3.us-east-2.amazonaws.com/{path}" )), Err(error) => Err(error), } }