Merged in feature/download-pdf (pull request #216)

retrieve document by id and tests

* working

* missing files
This commit is contained in:
Jay Brown
2026-03-17 17:06:57 +00:00
parent aafe7d5b5f
commit 2eff52877b
16 changed files with 1152 additions and 343 deletions
+17
View File
@@ -15,6 +15,23 @@ import (
openapi_types "github.com/oapi-codegen/runtime/types"
)
// DownloadDocument streams the original uploaded document file to the client.
func (s *Controllers) DownloadDocument(ctx echo.Context, id DocumentID) error {
result, err := s.svc.DocumentDownload.GetDownload(ctx.Request().Context(), uuid.UUID(id))
if err != nil {
slog.Error("unable to download document", "error", err, "document_id", id)
return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Unable to download document: %s", err))
}
defer result.Body.Close()
ctx.Response().Header().Set("Content-Disposition",
fmt.Sprintf(`attachment; filename="%s"`, result.Filename))
ctx.Response().Header().Set("Content-Length",
fmt.Sprintf("%d", result.Size))
return ctx.Stream(http.StatusOK, result.ContentType, result.Body)
}
func (s *Controllers) UploadDocument(ctx echo.Context, clientId ClientID) error {
form, err := ctx.MultipartForm()
if err != nil {