mirror of
https://codeberg.org/PLG-Development/PLG-MuDiCS
synced 2026-07-05 16:37:09 +00:00
chore(display): cleaner file download handling (#30)
This commit is contained in:
+1
-8
@@ -295,14 +295,7 @@ func downloadFileRoute(ctx echo.Context) error {
|
|||||||
|
|
||||||
slog.Info("Serving file for download", "path", fullPath)
|
slog.Info("Serving file for download", "path", fullPath)
|
||||||
|
|
||||||
file, err := os.Open(fullPath)
|
return ctx.File(fullPath)
|
||||||
if err != nil {
|
|
||||||
slog.Error("Failed to open file", "file", fullPath, "error", err)
|
|
||||||
return ctx.JSON(http.StatusInternalServerError, shared.ErrorResponse{Description: "Failed to open file"})
|
|
||||||
}
|
|
||||||
defer file.Close()
|
|
||||||
|
|
||||||
return ctx.Stream(http.StatusOK, "application/octet-stream", file)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func openFileRoute(ctx echo.Context) error {
|
func openFileRoute(ctx echo.Context) error {
|
||||||
|
|||||||
Reference in New Issue
Block a user