✨ Support use rid to get file
This commit is contained in:
@ -92,7 +92,7 @@ func listAttachment(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
for _, item := range result {
|
||||
services.CacheAttachment(item.ID, item)
|
||||
services.CacheAttachment(item)
|
||||
}
|
||||
|
||||
return c.JSON(fiber.Map{
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
|
||||
"git.solsynth.dev/hydrogen/paperclip/pkg/internal/database"
|
||||
"git.solsynth.dev/hydrogen/paperclip/pkg/internal/gap"
|
||||
@ -18,9 +19,16 @@ import (
|
||||
)
|
||||
|
||||
func openAttachment(c *fiber.Ctx) error {
|
||||
id, _ := c.ParamsInt("id", 0)
|
||||
id := c.Params("id")
|
||||
|
||||
metadata, err := services.GetAttachmentByID(uint(id))
|
||||
var err error
|
||||
var metadata models.Attachment
|
||||
|
||||
if numericId, numericErr := strconv.Atoi(id); numericErr == nil {
|
||||
metadata, err = services.GetAttachmentByID(uint(numericId))
|
||||
} else {
|
||||
metadata, err = services.GetAttachmentByRID(id)
|
||||
}
|
||||
if err != nil {
|
||||
return fiber.NewError(fiber.StatusNotFound)
|
||||
}
|
||||
|
Reference in New Issue
Block a user