diff options
| author | Santo Cariotti <santo@dcariotti.me> | 2022-09-12 12:03:12 +0000 |
|---|---|---|
| committer | Santo Cariotti <santo@dcariotti.me> | 2022-09-12 12:03:12 +0000 |
| commit | 56e50564e87cc764fc5b815f19aa56560f78e4d3 (patch) | |
| tree | f97899198cb722b6b9b2eab00d3a7f20fef5f354 /src/routes | |
| parent | 63b49b0876457a1bce9405a571f3c9b97a270fb4 (diff) | |
Keep saved filepath in the database
Diffstat (limited to 'src/routes')
| -rw-r--r-- | src/routes/model.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/routes/model.rs b/src/routes/model.rs index 3d5084c..f85e9a7 100644 --- a/src/routes/model.rs +++ b/src/routes/model.rs @@ -3,7 +3,7 @@ use crate::errors::AppError; use crate::files::upload; use crate::models::{ auth::Claims, - model::{Model, ModelCreate, ModelUser}, + model::{Model, ModelCreate, ModelUpload, ModelUser}, }; use crate::pagination::Pagination; use axum::{ @@ -61,7 +61,7 @@ async fn upload_model_file( claims: Claims, Path(model_id): Path<i32>, ContentLengthLimit(multipart): ContentLengthLimit<Multipart, { MAX_UPLOAD_FILE_SIZE }>, -) -> Result<String, AppError> { +) -> Result<Json<ModelUpload>, AppError> { let model = match Model::find_by_id(model_id).await { Ok(model) => model, Err(_) => { @@ -75,7 +75,9 @@ async fn upload_model_file( match upload(multipart, vec!["stl"]).await { Ok(saved_file) => { - return Ok(format!("Uploaded {}", saved_file)); + let model_file = ModelUpload::create(ModelUpload::new(saved_file, model_id)).await?; + + return Ok(Json(model_file)); } Err(e) => Err(e), } |
