Fix noms de fichiers avec symboles spéciaux
Utiliser `url.QueryUnescape()` pour s'assurer que les noms de fichiers soient bien affichés
This commit is contained in:
parent
346df72955
commit
97254e6fa1
2 changed files with 33 additions and 27 deletions
|
@ -9,7 +9,6 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"regexp"
|
||||
|
||||
"embed"
|
||||
"html/template"
|
||||
|
@ -417,14 +416,16 @@ func handleV1DocumentCreate(c echo.Context) error {
|
|||
}
|
||||
defer src.Close()
|
||||
|
||||
reg, err := regexp.Compile("[^.a-zA-Z0-9_-]+")
|
||||
if err != nil {
|
||||
return c.Render(http.StatusInternalServerError, "documentation-html", nil)
|
||||
}
|
||||
/*
|
||||
reg, err := regexp.Compile("[^.a-zA-Z0-9_-]+")
|
||||
if err != nil {
|
||||
return c.Render(http.StatusInternalServerError, "documentation-html", nil)
|
||||
}
|
||||
|
||||
filename_processed := reg.ReplaceAllString(form_file.Filename, "")
|
||||
filename_processed := reg.ReplaceAllString(form_file.Filename, "")
|
||||
*/
|
||||
|
||||
info, err := mediaClient.MinioClient.PutObject(ctx, bucket, filename_processed, src, form_file.Size, minio.PutObjectOptions{
|
||||
info, err := mediaClient.MinioClient.PutObject(ctx, bucket, form_file.Filename, src, form_file.Size, minio.PutObjectOptions{
|
||||
ContentType: form_file.Header.Get("Content-Type"),
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -456,11 +457,6 @@ func handleV1DocumentRead(c echo.Context) error {
|
|||
}
|
||||
|
||||
if !allowed {
|
||||
/*
|
||||
return c.JSON(http.StatusBadRequest, map[string]string{
|
||||
"message": "Bucket is not allowed in server.documents.buckets",
|
||||
})
|
||||
*/
|
||||
return c.JSON(http.StatusNotFound, map[string]string{"message": "Not Found"})
|
||||
}
|
||||
|
||||
|
@ -658,23 +654,23 @@ func handleDocumentation(c echo.Context) error {
|
|||
// N'est pas présentement activé, car les fichiers sont processed
|
||||
// à la création de toute façon.
|
||||
/*
|
||||
reg, err := regexp.Compile("[^.a-zA-Z0-9_-]+")
|
||||
if err != nil {
|
||||
return c.Render(http.StatusInternalServerError, "documentation-html", nil)
|
||||
}
|
||||
reg, err := regexp.Compile("[^.a-zA-Z0-9_-]+")
|
||||
if err != nil {
|
||||
return c.Render(http.StatusInternalServerError, "documentation-html", nil)
|
||||
}
|
||||
|
||||
var documents_processed []string
|
||||
var documents_processed []string
|
||||
|
||||
for _, document := range documents {
|
||||
document_processed := reg.ReplaceAllString(document, "")
|
||||
documents_processed = append(documents_processed, document_processed)
|
||||
}
|
||||
for _, document := range documents {
|
||||
document_processed := reg.ReplaceAllString(document, "")
|
||||
documents_processed = append(documents_processed, document_processed)
|
||||
}
|
||||
documents_processed := documents
|
||||
*/
|
||||
documents_processed := documents
|
||||
|
||||
data = append(data, Bucket{
|
||||
Name: bucket,
|
||||
Documents: documents_processed,
|
||||
Documents: documents,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue