admin: Fix file download from admin interface

This commit is contained in:
nemunaire 2022-11-21 14:56:32 +01:00
parent 9bcf4a481e
commit abb277210c
2 changed files with 7 additions and 1 deletions

View File

@ -4,6 +4,8 @@ import (
"context" "context"
"log" "log"
"net/http" "net/http"
"path/filepath"
"strings"
"time" "time"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
@ -33,6 +35,10 @@ func NewApp(cfg *settings.Settings, baseURL string, bind string) App {
router.GET("/", func(c *gin.Context) { router.GET("/", func(c *gin.Context) {
c.Redirect(http.StatusFound, baseURL) c.Redirect(http.StatusFound, baseURL)
}) })
router.GET(filepath.Dir(baseURL)+"/files/*_", func(c *gin.Context) {
path := c.Request.URL.Path
c.Redirect(http.StatusFound, filepath.Join(baseURL, strings.TrimPrefix(path, filepath.Dir(baseURL))))
})
baserouter = router.Group(baseURL) baserouter = router.Group(baseURL)

View File

@ -96,7 +96,7 @@
<form ng-submit="saveFile()" class="list-group-item bg-light text-dark" ng-repeat="file in files"> <form ng-submit="saveFile()" class="list-group-item bg-light text-dark" ng-repeat="file in files">
<div class="row form-group"> <div class="row form-group">
<input type="text" ng-model="file.name" class="col form-control form-control-sm" placeholder="Nom de fichier"> <input type="text" ng-model="file.name" class="col form-control form-control-sm" placeholder="Nom de fichier">
<a href="/files{{file.path}}" class="btn btn-sm btn-secondary col-auto"><span class="glyphicon glyphicon-download" aria-hidden="true"></span></a> <a href="../files{{file.path}}" class="btn btn-sm btn-secondary col-auto"><span class="glyphicon glyphicon-download" aria-hidden="true"></span></a>
<button type="submit" class="btn btn-sm btn-success col-auto"><span class="glyphicon glyphicon-ok" aria-hidden="true"></span></button><br> <button type="submit" class="btn btn-sm btn-success col-auto"><span class="glyphicon glyphicon-ok" aria-hidden="true"></span></button><br>
<button type="button" ng-click="deleteFile()" class="btn btn-sm btn-danger col-auto"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></button> <button type="button" ng-click="deleteFile()" class="btn btn-sm btn-danger col-auto"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></button>
</div> </div>