Added image upload logic
This commit is contained in:
parent
403064ac6c
commit
1cfe059b5c
@ -1,4 +1,5 @@
|
|||||||
use actix_web_utils::extensions::typed_response::TypedHttpResponse;
|
use actix_web_utils::extensions::typed_response::TypedHttpResponse;
|
||||||
|
use err::MessageResource;
|
||||||
use jl_types::{
|
use jl_types::{
|
||||||
domain::{
|
domain::{
|
||||||
agent::Agent, contact::Contact, count::Count, location::Location, project::Project,
|
agent::Agent, contact::Contact, count::Count, location::Location, project::Project,
|
||||||
@ -15,7 +16,7 @@ use jl_types::{
|
|||||||
use sqlx::PgPool;
|
use sqlx::PgPool;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::{dao, handle_db_read_op, handle_db_write_op, handle_tx, success, unwrap_or_not_found, utils::s3::{Item}};
|
use crate::{dao, handle_db_read_op, handle_db_write_op, handle_tx, success, unwrap_or_not_found, utils::s3::{Item, self}};
|
||||||
|
|
||||||
//
|
//
|
||||||
// Insert Methods
|
// Insert Methods
|
||||||
@ -196,7 +197,9 @@ pub async fn get_contact_count(conn: &PgPool) -> TypedHttpResponse<Count> {
|
|||||||
success!(count)
|
success!(count)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn upload_image(_client: &aws_sdk_s3::Client, _item: Item, _id: Uuid, _file_name: String) -> TypedHttpResponse<String> {
|
pub async fn upload_image(client: &aws_sdk_s3::Client, item: Item, id: Uuid, file_name: String) -> TypedHttpResponse<String> {
|
||||||
|
match s3::upload_image(client, id, item, file_name).await {
|
||||||
success!(String::new())
|
Ok(url) => success!(url),
|
||||||
|
Err(error) => return TypedHttpResponse::return_standard_error(400, MessageResource::new_from_string(error.to_string())),
|
||||||
|
};
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user