Send file info

This commit is contained in:
Neeraj Gupta
2025-07-21 16:44:22 +05:30
parent c57d467965
commit 6bed9bd8a2
3 changed files with 14 additions and 2 deletions

View File

@@ -27,7 +27,14 @@ func (h *FileHandler) ShareUrl(c *gin.Context) {
}
func (h *FileHandler) LinkInfo(c *gin.Context) {
resp, err := h.FileUrlCtrl.Info(c)
if err != nil {
handler.Error(c, stacktrace.Propagate(err, ""))
return
}
c.JSON(http.StatusOK, gin.H{
"file": resp,
})
}
func (h *FileHandler) LinkThumbnail(c *gin.Context) {

View File

@@ -110,6 +110,11 @@ func (c *FileLinkController) UpdateSharedUrl(ctx *gin.Context, req ente.UpdateFi
return c.mapRowToFileUrl(ctx, fileLinkRow), nil
}
func (c *FileLinkController) Info(ctx *gin.Context) (*ente.File, error) {
accessContext := auth.MustGetFileLinkAccessContext(ctx)
return c.FileRepo.GetFileAttributes(accessContext.FileID)
}
// VerifyPassword verifies if the user has provided correct pw hash. If yes, it returns a signed jwt token which can be
// used by the client to pass in other requests for public collection.
// Having a separate endpoint for password validation allows us to easily rate-limit the attempts for brute-force

View File

@@ -20,7 +20,7 @@ import (
"github.com/sirupsen/logrus"
)
var filePasswordWhiteListedURLs = []string{"/file-link/info", "/file-link/verify-password"}
var filePasswordWhiteListedURLs = []string{"/file-link/pass-info", "/file-link/verify-password"}
// FileLinkMiddleware intercepts and authenticates incoming requests
type FileLinkMiddleware struct {