telegram
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
||||
"fmt"
|
||||
"math"
|
||||
"mime/multipart"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
@@ -492,25 +491,10 @@ func DownloadDocumento(c *fiber.Ctx) error {
|
||||
if !strings.HasPrefix(clean, "uploads/") {
|
||||
return c.Status(403).JSON(fiber.Map{"error": "Acceso denegado"})
|
||||
}
|
||||
nombre := item.OriginalName
|
||||
if nombre == "" {
|
||||
nombre = item.Nombre
|
||||
}
|
||||
c.Set("Content-Disposition", attachmentDisposition(nombre))
|
||||
c.Set("Content-Disposition", fmt.Sprintf(`attachment; filename="%s"`, item.OriginalName))
|
||||
return c.SendFile(clean)
|
||||
}
|
||||
|
||||
// attachmentDisposition genera un header Content-Disposition con fallback ASCII y encoding RFC 5987.
|
||||
func attachmentDisposition(name string) string {
|
||||
safe := strings.Map(func(r rune) rune {
|
||||
if r > 127 || r == '"' || r == '\\' || r == '/' || r == '\n' || r == '\r' {
|
||||
return '_'
|
||||
}
|
||||
return r
|
||||
}, name)
|
||||
return fmt.Sprintf(`attachment; filename="%s"; filename*=UTF-8''%s`, safe, url.PathEscape(name))
|
||||
}
|
||||
|
||||
// ─── Tickets (admin) ──────────────────────────────────────────────────────────
|
||||
|
||||
func GetTickets(c *fiber.Ctx) error {
|
||||
|
||||
Reference in New Issue
Block a user