feat: add thumbnail metadata and download endpoint
- Extend `BoxFile` with thumbnail path/status fields and internal URL - Populate `ThumbnailURL` when a thumbnail path is present during decoration - Add `/box/:id/thumbnails/:file_id` route and handler to serve JPEG thumbnails - Introduce thumbnail status constants to standardize processing state reportingfeat: add thumbnail metadata and download endpoint - Extend `BoxFile` with thumbnail path/status fields and internal URL - Populate `ThumbnailURL` when a thumbnail path is present during decoration - Add `/box/:id/thumbnails/:file_id` route and handler to serve JPEG thumbnails - Introduce thumbnail status constants to standardize processing state reporting
This commit is contained in:
@@ -208,6 +208,33 @@ func handleDownloadFile(ctx *gin.Context) {
|
||||
ctx.FileAttachment(path, filename)
|
||||
}
|
||||
|
||||
func handleDownloadThumbnail(ctx *gin.Context) {
|
||||
boxID := ctx.Param("id")
|
||||
fileID := ctx.Param("file_id")
|
||||
if !boxstore.ValidBoxID(boxID) {
|
||||
ctx.String(http.StatusBadRequest, "Invalid box id")
|
||||
return
|
||||
}
|
||||
|
||||
if _, _, authorized := authorizeBoxRequest(ctx, boxID, true); !authorized {
|
||||
return
|
||||
}
|
||||
|
||||
path, ok := boxstore.ThumbnailFilePath(boxID, fileID)
|
||||
if !ok {
|
||||
ctx.String(http.StatusBadRequest, "Invalid thumbnail")
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := os.Stat(path); err != nil {
|
||||
ctx.String(http.StatusNotFound, "Thumbnail not found")
|
||||
return
|
||||
}
|
||||
|
||||
ctx.Header("Content-Type", "image/jpeg")
|
||||
ctx.File(path)
|
||||
}
|
||||
|
||||
func handleCreateBox(ctx *gin.Context) {
|
||||
boxID, err := boxstore.NewBoxID()
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user