From 438daa7bb5b36bee09311bf66b043cbed6eba9cb Mon Sep 17 00:00:00 2001 From: Emmie Maeda Date: Sun, 8 Sep 2024 23:56:50 -0400 Subject: [PATCH] Add proper StartFileUploadOutput struct. --- deepwell/src/services/file/service.rs | 13 +++++++++---- deepwell/src/services/file/structs.rs | 8 ++++++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/deepwell/src/services/file/service.rs b/deepwell/src/services/file/service.rs index b40511f1a28..6e8380075ab 100644 --- a/deepwell/src/services/file/service.rs +++ b/deepwell/src/services/file/service.rs @@ -78,8 +78,7 @@ impl FileService { }; let file = model.insert(txn).await?; - - FileRevisionService::create_pending( + let file_revision = FileRevisionService::create_pending( ctx, CreatePendingFileRevision { site_id, @@ -91,7 +90,13 @@ impl FileService { comments: revision_comments, }, ) - .await + .await?; + + Ok(StartFileUploadOutput { + pending_blob_id: pending.pending_blob_id, + presign_url: pending.presign_url, + file_revision_id: file_revision.file_revision_id, + }) } pub async fn finish_new_upload( @@ -108,7 +113,7 @@ impl FileService { site_id, page_id, file_id, pending_blob_id, ); - // Ensure file exists + // Ensure a pending file exists let txn = ctx.transaction(); let row = File::find() .filter( diff --git a/deepwell/src/services/file/structs.rs b/deepwell/src/services/file/structs.rs index 9b52d9ac861..4cf87c520b9 100644 --- a/deepwell/src/services/file/structs.rs +++ b/deepwell/src/services/file/structs.rs @@ -39,8 +39,12 @@ pub struct StartFileUpload { pub bypass_filter: bool, } -// TODO -pub type StartFileUploadOutput = CreateFirstFileRevisionOutput; +#[derive(Serialize, Debug, Clone)] +pub struct StartFileUploadOutput { + pub pending_blob_id: i64, + pub presign_url: String, + pub file_revision_id: i64, +} #[derive(Deserialize, Debug, Clone)] pub struct FinishUploadFile {