diff --git a/deepwell/src/endpoints/file.rs b/deepwell/src/endpoints/file.rs index db2d948a7b4..c909bdea9d7 100644 --- a/deepwell/src/endpoints/file.rs +++ b/deepwell/src/endpoints/file.rs @@ -21,12 +21,11 @@ use super::prelude::*; use crate::models::file::Model as FileModel; use crate::models::file_revision::Model as FileRevisionModel; -use crate::services::blob::BlobService; +use crate::services::blob::{BlobMetadata, BlobService, GetBlobOutput}; use crate::services::file::{ DeleteFile, DeleteFileOutput, EditFile, EditFileOutput, FinishFileCreation, - FinishFileCreationOutput, GetBlobOutput, GetFileDetails, GetFileOutput, MoveFile, - MoveFileOutput, RestoreFile, RestoreFileOutput, StartFileCreation, - StartFileCreationOutput, + FinishFileCreationOutput, GetFileDetails, GetFileOutput, MoveFile, MoveFileOutput, + RestoreFile, RestoreFileOutput, StartFileCreation, StartFileCreationOutput, }; use crate::services::Result; use crate::web::{Bytes, FileDetails}; @@ -41,14 +40,19 @@ pub async fn blob_get( info!("Getting blob for S3 hash"); let hash: Bytes = params.parse()?; let data = BlobService::get(ctx, hash.as_ref()).await?; - let metadata = BlobService::get_metadata(ctx, hash.as_ref()).await?; - let output = GetBlobOutput { + let BlobMetadata { + mime, + size, + created_at, + } = BlobService::get_metadata(ctx, hash.as_ref()).await?; + + Ok(GetBlobOutput { data, - mime: metadata.mime, - size: metadata.size, - }; - Ok(output) + mime, + size, + created_at, + }) } pub async fn file_get( @@ -114,16 +118,18 @@ pub async fn file_create_finish( // TODO pub async fn file_edit_start( ctx: &ServiceContext<'_>, - params: Params<'static>, + _params: Params<'static>, ) -> Result<()> { + let _ = FileService::start_edit_upload(ctx).await?; todo!() } // TODO pub async fn file_edit_finish( ctx: &ServiceContext<'_>, - params: Params<'static>, + _params: Params<'static>, ) -> Result<()> { + let _ = FileService::finish_edit_upload(ctx).await?; todo!() } diff --git a/deepwell/src/services/blob/structs.rs b/deepwell/src/services/blob/structs.rs index d931ac264a4..9abc342e791 100644 --- a/deepwell/src/services/blob/structs.rs +++ b/deepwell/src/services/blob/structs.rs @@ -35,3 +35,11 @@ pub struct BlobMetadata { pub size: i64, pub created_at: OffsetDateTime, } + +#[derive(Serialize, Debug, Clone)] +pub struct GetBlobOutput { + pub data: Vec, + pub mime: String, + pub size: i64, + pub created_at: OffsetDateTime, +} diff --git a/deepwell/src/services/file/service.rs b/deepwell/src/services/file/service.rs index f33afad5586..4b94e88fe6a 100644 --- a/deepwell/src/services/file/service.rs +++ b/deepwell/src/services/file/service.rs @@ -159,14 +159,12 @@ impl FileService { /// Edits a file by uploading a new file version. /// TODO needs to be implemented - pub async fn start_edit_upload( - ctx: &ServiceContext<'_>, - ) -> Result<()> { + pub async fn start_edit_upload(_ctx: &ServiceContext<'_>) -> Result { todo!() } // TODO - pub async fn finish_edit_upload(ctx: &ServiceContext<'_>) -> Result<()> { + pub async fn finish_edit_upload(_ctx: &ServiceContext<'_>) -> Result { todo!() } diff --git a/deepwell/src/services/file/structs.rs b/deepwell/src/services/file/structs.rs index d499c802d62..b510dbef2f6 100644 --- a/deepwell/src/services/file/structs.rs +++ b/deepwell/src/services/file/structs.rs @@ -94,13 +94,6 @@ pub struct GetFileOutput { pub hidden_fields: Vec, } -#[derive(Serialize, Debug, Clone)] -pub struct GetBlobOutput { - pub data: Vec, - pub mime: String, - pub size: i64, -} - #[derive(Deserialize, Debug, Clone)] pub struct EditFile { pub site_id: i64, diff --git a/deepwell/src/services/import/service.rs b/deepwell/src/services/import/service.rs index f3ec50cb27f..22835d0c71a 100644 --- a/deepwell/src/services/import/service.rs +++ b/deepwell/src/services/import/service.rs @@ -73,6 +73,7 @@ impl ImportService { let output = BlobService::create(ctx, &bytes).await?; Some(output.hash.to_vec()) */ + let _ = bytes; todo!() } }; diff --git a/deepwell/src/services/user/service.rs b/deepwell/src/services/user/service.rs index a88069f938d..18a80135c5a 100644 --- a/deepwell/src/services/user/service.rs +++ b/deepwell/src/services/user/service.rs @@ -432,6 +432,7 @@ impl UserService { Some(hash.to_vec()) */ + let _ = blob; todo!() } };