Compare commits
12
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf46c3f68a | ||
|
|
ccad50f414 | ||
|
|
b9a40a20dd | ||
|
|
9f111b5efb
|
||
|
|
2b602bded6
|
||
|
|
6a780d5baf
|
||
|
|
88d5fa2780
|
||
|
|
8b2b18f9b5
|
||
|
|
8660cd479f
|
||
|
|
9c3e9cd204
|
||
|
|
f406ed1961 | ||
|
|
6ed1d00a32 |
No files matched your search
@@ -21,7 +21,7 @@ jobs:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
toolchain: 1.97
|
||||
toolchain: 1.99
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- run: cargo check
|
||||
|
||||
@@ -32,7 +32,7 @@ jobs:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
toolchain: 1.97
|
||||
toolchain: 1.99
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- run: cargo test
|
||||
|
||||
@@ -43,7 +43,7 @@ jobs:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
toolchain: 1.97
|
||||
toolchain: 1.99
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- run: rustup component add rustfmt
|
||||
- run: cargo fmt --all -- --check
|
||||
@@ -55,7 +55,7 @@ jobs:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
toolchain: 1.97
|
||||
toolchain: 1.99
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- run: rustup component add clippy
|
||||
- run: cargo clippy -- -D warnings
|
||||
@@ -67,7 +67,7 @@ jobs:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
toolchain: 1.97
|
||||
toolchain: 1.99
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- run: cargo build
|
||||
|
||||
@@ -20,7 +20,7 @@ jobs:
|
||||
- name: Install Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: 1.97
|
||||
toolchain: 1.99
|
||||
components: cargo
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
|
||||
|
||||
Generated
+375
-365
File diff suppressed because it is too large.
Load diff
+6
-6
@@ -1,13 +1,13 @@
|
||||
[package]
|
||||
name = "labyrinth"
|
||||
version = "0.0.2"
|
||||
version = "0.0.8"
|
||||
edition = "2024"
|
||||
license = "MIT"
|
||||
description = "Library for managing soaricarus storage"
|
||||
|
||||
[dependencies]
|
||||
aws-config = { version = "1.9.0", features = ["behavior-version-latest"] }
|
||||
aws-sdk-s3 = { version = "1.138.1" }
|
||||
time = "0.3.53"
|
||||
tokio = { version = "1.53.0", features = ["full"] }
|
||||
uuid = "1.24.0"
|
||||
aws-config = { version = "1.13.0", features = ["behavior-version-latest"] }
|
||||
aws-sdk-s3 = { version = "1.157.0" }
|
||||
time = "0.3.55"
|
||||
tokio = { version = "1.54.1", features = ["full"] }
|
||||
uuid = "1.29.0"
|
||||
+27
-6
@@ -47,16 +47,17 @@ pub enum Error {
|
||||
}
|
||||
|
||||
impl Labyrinth {
|
||||
/// Upload object to the bucket
|
||||
pub async fn upload(
|
||||
&self,
|
||||
file_key: &str,
|
||||
data: &Data,
|
||||
) -> Result<aws_sdk_s3::operation::put_object::PutObjectOutput, Error> {
|
||||
) -> Result<aws_sdk_s3::operation::put_object::PutObjectOutput, Box<Error>> {
|
||||
let client = init_client(&self.config).await;
|
||||
let data_content = if data.raw_data.is_empty() {
|
||||
match load_data(&data.filepath).await {
|
||||
Ok(content) => content,
|
||||
Err(err) => return Err(Error::Info(err.to_string())),
|
||||
Err(err) => return Err(Box::new(Error::Info(err.to_string()))),
|
||||
}
|
||||
} else {
|
||||
data.raw_data.to_owned()
|
||||
@@ -73,11 +74,12 @@ impl Labyrinth {
|
||||
.await
|
||||
{
|
||||
Ok(response) => Ok(response),
|
||||
Err(err) => Err(Error::Info(err.to_string())),
|
||||
Err(err) => Err(Box::new(Error::Info(err.to_string()))),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn download(&self, file_key: &str) -> Result<Vec<u8>, Error> {
|
||||
/// Download object from the bucket
|
||||
pub async fn download(&self, file_key: &str) -> Result<Vec<u8>, Box<Error>> {
|
||||
let client = init_client(&self.config).await;
|
||||
|
||||
match client
|
||||
@@ -97,10 +99,29 @@ impl Labyrinth {
|
||||
let raw_data = bytes.to_vec();
|
||||
Ok(raw_data)
|
||||
}
|
||||
Err(err) => Err(Error::Info(err.to_string())),
|
||||
Err(err) => Err(Box::new(Error::Info(err.to_string()))),
|
||||
}
|
||||
}
|
||||
Err(err) => Err(Error::Info(err.to_string())),
|
||||
Err(err) => Err(Box::new(Error::Info(err.to_string()))),
|
||||
}
|
||||
}
|
||||
|
||||
/// Delete an object from the bucket
|
||||
pub async fn delete(
|
||||
&self,
|
||||
file_key: &str,
|
||||
) -> Result<aws_sdk_s3::operation::delete_object::DeleteObjectOutput, Box<Error>> {
|
||||
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(Box::new(Error::Info(err.to_string()))),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user