tainacan / tainacan

A flexible and powerful repository platform for WordPress
https://tainacan.org
GNU General Public License v3.0
121 stars 28 forks source link

Create function to get file name from URL headers #929

Open vnmedeiros opened 1 week ago

vnmedeiros commented 1 week ago

Context and motivation

The function basename is currently being used to extract the file name from a URL when importing files from external sources. However, using basename may not always yield accurate file names, especially if the file name is specified in the Content-Dispositionheader of the HTTP response, which is common in file downloads.

Ideal solution

The create function should retrieve the file name from a URL by first attempting to read the Content-Disposition header. If this header is not available, the function should fall back to using basename.

vnmedeiros commented 1 week ago

PR: https://github.com/tainacan/tainacan/pull/930