2026-01-29 23:55:41 +00:00
|
|
|
package rmo
|
2026-01-21 18:26:48 +00:00
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"net/http"
|
|
|
|
|
|
2026-03-12 23:49:16 +00:00
|
|
|
"github.com/Gleipnir-Technology/nidus-sync/platform/file"
|
2026-01-21 18:26:48 +00:00
|
|
|
"github.com/go-chi/chi/v5"
|
2026-02-08 01:44:44 +00:00
|
|
|
"github.com/google/uuid"
|
2026-01-21 18:26:48 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// ServeImageByUUID reads an image with the given UUID from disk and writes it to the HTTP response
|
|
|
|
|
func getImageByUUID(w http.ResponseWriter, r *http.Request) {
|
2026-02-08 01:44:44 +00:00
|
|
|
u := chi.URLParam(r, "uuid")
|
|
|
|
|
if u == "" {
|
2026-01-21 18:26:48 +00:00
|
|
|
http.NotFound(w, r)
|
|
|
|
|
return
|
|
|
|
|
}
|
2026-02-08 01:44:44 +00:00
|
|
|
uid, err := uuid.Parse(u)
|
|
|
|
|
if err != nil {
|
|
|
|
|
http.Error(w, "Failed to parse uuid", http.StatusBadRequest)
|
|
|
|
|
return
|
|
|
|
|
}
|
2026-03-12 23:49:16 +00:00
|
|
|
file.PublicImageFileToResponse(w, uid)
|
2026-01-21 18:26:48 +00:00
|
|
|
}
|