image acces api : GWM

This commit is contained in:
Gowtham M 2025-08-29 10:32:31 +05:30
parent e61b684759
commit eb4d576607
9 changed files with 27 additions and 1 deletions

BIN
approve.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 969 B

28
main.go
View File

@ -13,7 +13,7 @@ import (
"net/http"
"net/mail"
"os"
"path/filepath"
"pocketbase/utils"
"strings"
"time"
@ -587,6 +587,32 @@ func main() {
app.OnBeforeServe().Add(func(e *core.ServeEvent) error {
e.Router.GET("/api/getImagePath", func(c echo.Context) error {
fileName := c.QueryParam("file")
if fileName == "" {
return c.JSON(http.StatusBadRequest, map[string]string{
"error": "missing file parameter",
})
}
// Static files folder
staticPath := "./pb_public"
fullPath := filepath.Join(staticPath, fileName)
// Check if file exists
if _, err := os.Stat(fullPath); os.IsNotExist(err) {
return c.JSON(http.StatusNotFound, map[string]string{
"error": "file not found",
})
}
// Serve the file directly (browser will show the image)
return c.File(fullPath)
})
// e.Router.Static("/static", "./pb_public")
e.Router.GET("/pw/auth/confirm-password-reset/:token", func(c echo.Context) error {
return c.File("pb_public/confirm_password_reset.html")
})

BIN
pb_data/data.db-shm Executable file

Binary file not shown.

0
pb_data/data.db-wal Executable file
View File

BIN
pb_data/logs.db-shm Normal file

Binary file not shown.

BIN
pb_data/logs.db-wal Normal file

Binary file not shown.

BIN
pb_public/approve.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 969 B

BIN
pb_public/reject.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 970 B

BIN
reject.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 970 B