Adding initial scaffolding to rename the repository
Signed-off-by: Kris Nóva <kris@nivenly.com>
This commit is contained in:
parent
c7472582a7
commit
0f880ac1fa
46 changed files with 5707 additions and 674 deletions
33
internal/api/file.go
Normal file
33
internal/api/file.go
Normal 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)
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue