Adding initial scaffolding to rename the repository

Signed-off-by: Kris Nóva <kris@nivenly.com>
This commit is contained in:
Kris Nóva 2021-01-30 22:41:23 -08:00
parent c7472582a7
commit 0f880ac1fa
46 changed files with 5707 additions and 674 deletions

33
internal/api/file.go Normal file
View file

@ -0,0 +1,33 @@
package api
import (
"net/http"
"github.com/gin-gonic/gin"
"github.com/photoprism/photoprism/internal/acl"
"github.com/photoprism/photoprism/internal/query"
)
// GET /api/v1/files/:hash
//
// Parameters:
// hash: string SHA-1 hash of the file
func GetFile(router *gin.RouterGroup) {
router.GET("/files/:hash", func(c *gin.Context) {
s := Auth(SessionID(c), acl.ResourceFiles, acl.ActionRead)
if s.Invalid() {
AbortUnauthorized(c)
return
}
p, err := query.FileByHash(c.Param("hash"))
if err != nil {
AbortEntityNotFound(c)
return
}
c.JSON(http.StatusOK, p)
})
}