Show images from public reports
This commit is contained in:
parent
361933994f
commit
1970ccb13e
3 changed files with 12 additions and 1 deletions
10
api/api.go
10
api/api.go
|
|
@ -156,6 +156,16 @@ func apiImagePost(w http.ResponseWriter, r *http.Request, org *models.Organizati
|
|||
w.WriteHeader(http.StatusAccepted)
|
||||
}
|
||||
|
||||
func apiImageContentGet(w http.ResponseWriter, r *http.Request, org *models.Organization, u *models.User) {
|
||||
u_str := chi.URLParam(r, "uuid")
|
||||
imageUUID, err := uuid.Parse(u_str)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Failed to parse image UUID")
|
||||
http.Error(w, "Failed to parse image UUID", http.StatusBadRequest)
|
||||
}
|
||||
userfile.PublicImageFileToResponse(w, imageUUID)
|
||||
w.WriteHeader(http.StatusOK)
|
||||
}
|
||||
func apiImageContentPost(w http.ResponseWriter, r *http.Request, org *models.Organization, u *models.User) {
|
||||
u_str := chi.URLParam(r, "uuid")
|
||||
imageUUID, err := uuid.Parse(u_str)
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ func toImageURLs(m map[string][]uuid.UUID, id string) []string {
|
|||
}
|
||||
urls := make([]string, len(uuids))
|
||||
for i, u := range uuids {
|
||||
urls[i] = config.MakeURLNidus("/api/image/%s", u.String())
|
||||
urls[i] = config.MakeURLNidus("/api/image/%s/content", u.String())
|
||||
}
|
||||
return urls
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ func AddRoutes(r chi.Router) {
|
|||
r.Method("POST", "/audio/{uuid}", auth.NewEnsureAuth(apiAudioPost))
|
||||
r.Method("POST", "/audio/{uuid}/content", auth.NewEnsureAuth(apiAudioContentPost))
|
||||
r.Method("POST", "/image/{uuid}", auth.NewEnsureAuth(apiImagePost))
|
||||
r.Method("GET", "/image/{uuid}/content", auth.NewEnsureAuth(apiImageContentGet))
|
||||
r.Method("POST", "/image/{uuid}/content", auth.NewEnsureAuth(apiImageContentPost))
|
||||
r.Method("GET", "/leads", authenticatedHandlerJSON(listLead))
|
||||
r.Method("POST", "/leads", authenticatedHandlerJSONPost(postLeads))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue