remove download endpoint

This commit is contained in:
2025-10-28 00:17:57 +01:00
parent 7abc10acde
commit b9d84fa72b
5 changed files with 12 additions and 101 deletions
-49
View File
@@ -215,15 +215,6 @@ pub struct DocumentDetailResponse {
pub document: DocumentResponse,
}
#[derive(Serialize, ToSchema)]
pub struct DocumentDownloadResponse {
pub url: String,
pub expires_in: u64,
pub filename: String,
pub content_type: Option<String>,
pub size_bytes: i64,
}
#[derive(Serialize, ToSchema)]
pub struct BulkReanalyzeResponse {
pub queued: usize,
@@ -1211,46 +1202,6 @@ pub async fn get_document_version(
}))
}
pub async fn download_document(
State(state): State<AppState>,
Path(document_id): Path<Uuid>,
TenantScopedConn {
mut conn,
tenant_id,
..
}: TenantScopedConn,
) -> AppResult<Json<DocumentDownloadResponse>> {
let doc: Document = documents::table
.find(document_id)
.filter(documents::tenant_id.eq(tenant_id))
.first(&mut conn)?;
if doc.deleted_at.is_some() {
return Err(AppError::not_found());
}
let version: DocumentVersion = document_versions::table
.find(doc.current_version_id)
.first(&mut conn)?;
let storage = state.storage_for_tenant(tenant_id)?;
let presigned_url = storage
.presign_get_object(
&version.s3_key,
Duration::from_secs(PRESIGNED_URL_EXPIRY_SECONDS),
)
.await
.map_err(|err| AppError::internal(format!("failed to generate download URL: {err}")))?;
Ok(Json(DocumentDownloadResponse {
url: presigned_url,
expires_in: PRESIGNED_URL_EXPIRY_SECONDS,
filename: doc.original_name.clone(),
content_type: doc.content_type.clone(),
size_bytes: version.size_bytes,
}))
}
pub async fn download_with_token(
State(state): State<AppState>,
Path(token): Path<String>,