mirror of
https://github.com/photoprism/photoprism.git
synced 2025-10-06 17:27:20 +08:00

These changes ensure that the new (SHA256) session ID is returned in the "session_id" field, so that developers have time to update their client implementations to use the new "access_token" field. Signed-off-by: Michael Mayer <michael@photoprism.app>
38 lines
721 B
Go
38 lines
721 B
Go
package api
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"github.com/photoprism/photoprism/internal/acl"
|
|
"github.com/photoprism/photoprism/internal/query"
|
|
"github.com/photoprism/photoprism/pkg/clean"
|
|
)
|
|
|
|
// GetFile returns file details as JSON.
|
|
//
|
|
// Request Parameters:
|
|
// - hash (string) SHA-1 hash of the file
|
|
//
|
|
// GET /api/v1/files/:hash
|
|
func GetFile(router *gin.RouterGroup) {
|
|
router.GET("/files/:hash", func(c *gin.Context) {
|
|
s := Auth(c, acl.ResourceFiles, acl.ActionView)
|
|
|
|
// Abort if permission was 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)
|
|
})
|
|
}
|