make notes api return any file (so images and etc can be sent)
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user