wings icon indicating copy to clipboard operation
wings copied to clipboard

Fix file path handling in download router

Open KroZen-Dev opened this issue 9 months ago • 0 comments

This pull request improves how file downloads are handled in the getDownloadFile function, focusing on safer and more accurate processing of file paths and filenames. The main changes include decoding URL-encoded file paths, extracting the correct filename for the download header, and updating imports to support these changes.

File path handling and download improvements:

  • Decoded the URL-encoded file path from the download token using url.QueryUnescape to ensure correct file access and prevent issues with encoded characters.
  • Updated the call to s.Filesystem().File to use the decoded filePath instead of the original token value, ensuring the correct file is accessed.
  • Used filepath.Base to extract the filename from the full file path for the Content-Disposition header, ensuring the downloaded file has the correct name regardless of the original path.

Dependency updates:

  • Added imports for net/url and path/filepath to support URL decoding and filename extraction.

🔗 Linked Issues: #5256

KroZen-Dev avatar Feb 08 '26 16:02 KroZen-Dev