nidus-sync/rmo/image.go

26 lines
580 B
Go
Raw Permalink Normal View History

package rmo
2026-01-21 18:26:48 +00:00
import (
"net/http"
"github.com/Gleipnir-Technology/nidus-sync/platform/file"
"github.com/google/uuid"
"github.com/gorilla/mux"
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) {
vars := mux.Vars(r)
u := vars["uuid"]
if u == "" {
2026-01-21 18:26:48 +00:00
http.NotFound(w, r)
return
}
uid, err := uuid.Parse(u)
if err != nil {
http.Error(w, "Failed to parse uuid", http.StatusBadRequest)
return
}
2026-04-01 21:23:28 +00:00
file.ImageFileToWriter(file.CollectionPublicImage, uid, w)
2026-01-21 18:26:48 +00:00
}