make notes api return any file (so images and etc can be sent)

This commit is contained in:
2026-01-13 12:13:20 +00:00
parent e756e160d7
commit 18c87c170b
3 changed files with 15 additions and 32 deletions

View File

@@ -2,18 +2,21 @@ package handlers
import (
"net/http"
"path/filepath"
"github.com/gin-gonic/gin"
)
func (store *Store) GetNote(ctx *gin.Context) {
func (store *Store) GetNoteFile(ctx *gin.Context) {
path := ctx.Param("path")
note, err := store.Notes.GetNote(path)
path, err := store.Notes.ParsePath(path)
if err != nil {
ctx.JSON(http.StatusNotFound, gin.H{"error": err.Error()})
return
}
ctx.JSON(http.StatusOK, note)
// Get the filename from path
filename := filepath.Base(path)
ctx.FileAttachment(path, filename)
}