You've already forked AstralRinth
forked from didirus/AstralRinth
Fix clippy errors + lint, use turbo CI
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
use crate::file_hosting::{DeleteFileData, FileHost, FileHostingError, UploadFileData};
|
||||
use crate::file_hosting::{
|
||||
DeleteFileData, FileHost, FileHostingError, UploadFileData,
|
||||
};
|
||||
use async_trait::async_trait;
|
||||
use bytes::Bytes;
|
||||
use chrono::Utc;
|
||||
@@ -31,12 +33,23 @@ impl S3Host {
|
||||
endpoint: url.to_string(),
|
||||
}
|
||||
},
|
||||
Credentials::new(Some(access_token), Some(secret), None, None, None).map_err(|_| {
|
||||
FileHostingError::S3Error("Error while creating credentials".to_string())
|
||||
Credentials::new(
|
||||
Some(access_token),
|
||||
Some(secret),
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.map_err(|_| {
|
||||
FileHostingError::S3Error(
|
||||
"Error while creating credentials".to_string(),
|
||||
)
|
||||
})?,
|
||||
)
|
||||
.map_err(|_| {
|
||||
FileHostingError::S3Error("Error while creating Bucket instance".to_string())
|
||||
FileHostingError::S3Error(
|
||||
"Error while creating Bucket instance".to_string(),
|
||||
)
|
||||
})?;
|
||||
|
||||
Ok(S3Host { bucket })
|
||||
@@ -55,10 +68,16 @@ impl FileHost for S3Host {
|
||||
let content_sha512 = format!("{:x}", sha2::Sha512::digest(&file_bytes));
|
||||
|
||||
self.bucket
|
||||
.put_object_with_content_type(format!("/{file_name}"), &file_bytes, content_type)
|
||||
.put_object_with_content_type(
|
||||
format!("/{file_name}"),
|
||||
&file_bytes,
|
||||
content_type,
|
||||
)
|
||||
.await
|
||||
.map_err(|_| {
|
||||
FileHostingError::S3Error("Error while uploading file to S3".to_string())
|
||||
FileHostingError::S3Error(
|
||||
"Error while uploading file to S3".to_string(),
|
||||
)
|
||||
})?;
|
||||
|
||||
Ok(UploadFileData {
|
||||
@@ -82,7 +101,9 @@ impl FileHost for S3Host {
|
||||
.delete_object(format!("/{file_name}"))
|
||||
.await
|
||||
.map_err(|_| {
|
||||
FileHostingError::S3Error("Error while deleting file from S3".to_string())
|
||||
FileHostingError::S3Error(
|
||||
"Error while deleting file from S3".to_string(),
|
||||
)
|
||||
})?;
|
||||
|
||||
Ok(DeleteFileData {
|
||||
|
||||
Reference in New Issue
Block a user