From f406ed196145bb667587c13f4fd0866a1fa6e915 Mon Sep 17 00:00:00 2001 From: phoenix Date: Tue, 11 Aug 2026 10:39:12 -0400 Subject: [PATCH] Delete object (#3) Reviewed-on: http://git.kundeng.us/phoenix/labyrinth/pulls/3 --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/lib.rs | 21 +++++++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0bac2f4..42aa3f8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1370,7 +1370,7 @@ dependencies = [ [[package]] name = "labyrinth" -version = "0.0.3" +version = "0.0.4" dependencies = [ "aws-config", "aws-sdk-s3", diff --git a/Cargo.toml b/Cargo.toml index c9690f6..a4ebaff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "labyrinth" -version = "0.0.3" +version = "0.0.4" edition = "2024" license = "MIT" description = "Library for managing soaricarus storage" diff --git a/src/lib.rs b/src/lib.rs index d308129..c9e9686 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -47,6 +47,7 @@ pub enum Error { } impl Labyrinth { + /// Upload object to the bucket pub async fn upload( &self, file_key: &str, @@ -77,6 +78,7 @@ impl Labyrinth { } } + /// Download object from the bucket pub async fn download(&self, file_key: &str) -> Result, Error> { let client = init_client(&self.config).await; @@ -103,4 +105,23 @@ impl Labyrinth { Err(err) => Err(Error::Info(err.to_string())), } } + + /// Delete an object from the bucket + pub async fn delete( + &self, + file_key: &str, + ) -> Result { + let client = init_client(&self.config).await; + + match client + .delete_object() + .bucket(self.config.bucket.clone()) + .key(file_key) + .send() + .await + { + Ok(response) => Ok(response), + Err(err) => Err(Error::Info(err.to_string())), + } + } }