Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DownloadFile ¶
DownloadFile downloads a file from a URL and saves it to a temporary directory with security validation. It follows redirects up to a maximum of 10 times. The filename is determined in the following order: 1. From Content-Disposition header if present and valid 2. From the final URL after redirects if valid 3. Falls back to a timestamp-based name if both sources are invalid
The function implements several security measures: - Validates filenames to prevent directory traversal - Restricts filenames to alphanumeric characters, dots, hyphens, underscores, and spaces - Ensures final path remains within temporary directory - Verifies path safety after normalization
Returns the path to the downloaded file and any error encountered.
Types ¶
This section is empty.