chore: pc change
Started implementing delete functions.
This commit is contained in:
1 parent
3f53e8fda1
commit
5cafc7e757
3 files changed
+39
-1
No files matched your search
@@ -57,3 +57,29 @@ pub async fn upload_file(
|
||||
.map(|_| ())
|
||||
.map_err(ServerFnError::from)
|
||||
}
|
||||
|
||||
#[server]
|
||||
pub async fn delete_file(
|
||||
access_token: String,
|
||||
form_id: String,
|
||||
file_name: String
|
||||
) -> Result<(), ServerFnError> {
|
||||
use crate::utils::server::create_aws_config;
|
||||
use crate::pages::api::tokens::validate_and_get_token_info;
|
||||
|
||||
let user_claims = validate_and_get_token_info(access_token).await?;
|
||||
let subject = user_claims.subject;
|
||||
|
||||
let key = format!("{form_id}/{subject}/{file_name}");
|
||||
|
||||
let client = aws_sdk_s3::Client::new(&create_aws_config().await);
|
||||
|
||||
client
|
||||
.delete_object()
|
||||
.bucket("leptos-scholarhips")
|
||||
.key(key)
|
||||
.send()
|
||||
.await
|
||||
.map(|_| ())
|
||||
.map_err(ServerFnError::from)
|
||||
}
|
||||
@@ -28,3 +28,6 @@ pub static PROVIDER_CONTACT_TABLE: &str = "leptos-provider-contacts";
|
||||
|
||||
#[cfg(feature = "ssr")]
|
||||
pub static MAIN_TABLE_NAME: &str = "scholarships-main";
|
||||
|
||||
#[cfg(feature = "ssr")]
|
||||
pub static S3_BUCKET_NAME: &str = "leptos-scholarships";
|
||||
Reference in new issue
Block a user