mirror of
https://github.com/wgh136/nysoure.git
synced 2025-12-16 15:51:14 +00:00
feat: implement download token generation for secure file access
This commit is contained in:
@@ -225,7 +225,18 @@ func downloadFile(c fiber.Ctx) error {
|
||||
return err
|
||||
}
|
||||
if strings.HasPrefix(s, "http") {
|
||||
return c.Redirect().Status(fiber.StatusFound).To(s)
|
||||
uri, err := url.Parse(s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
token, err := utils.GenerateDownloadToken(s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
q := uri.Query()
|
||||
q.Set("token", token)
|
||||
uri.RawQuery = q.Encode()
|
||||
return c.Redirect().Status(fiber.StatusFound).To(uri.String())
|
||||
}
|
||||
data := map[string]string{
|
||||
"path": s,
|
||||
|
||||
Reference in New Issue
Block a user