mirror of
https://github.com/photoprism/photoprism.git
synced 2025-09-26 21:01:58 +08:00

These changes allow to configure the computer vision models through an optional vision.yml configuration file. Note that the API endpoints are not yet functional and require further work. Signed-off-by: Michael Mayer <michael@photoprism.app>
42 lines
933 B
Go
42 lines
933 B
Go
package api
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"github.com/photoprism/photoprism/internal/auth/acl"
|
|
"github.com/photoprism/photoprism/internal/entity/query"
|
|
"github.com/photoprism/photoprism/pkg/clean"
|
|
)
|
|
|
|
// GetFile returns file details as JSON.
|
|
//
|
|
// @Summary returns file details as JSON
|
|
// @Id GetFile
|
|
// @Tags Files
|
|
// @Produce json
|
|
// @Success 200 {object} entity.File
|
|
// @Failure 401,403,404,429 {object} i18n.Response
|
|
// @Param hash path string true "hash (string) SHA-1 hash of the file"
|
|
// @Router /api/v1/files/{hash} [get]
|
|
func GetFile(router *gin.RouterGroup) {
|
|
router.GET("/files/:hash", func(c *gin.Context) {
|
|
s := Auth(c, acl.ResourceFiles, acl.ActionView)
|
|
|
|
// Abort if permission is not granted.
|
|
if s.Abort(c) {
|
|
return
|
|
}
|
|
|
|
p, err := query.FileByHash(clean.Token(c.Param("hash")))
|
|
|
|
if err != nil {
|
|
AbortEntityNotFound(c)
|
|
return
|
|
}
|
|
|
|
c.JSON(http.StatusOK, p)
|
|
})
|
|
}
|