During a website migration involving a number of documents, mostly PDFs, that have very long filenames, example below, yes this long!
A very long filename of a PDF document here A very long filename of a PDF document here A very long filename of a PDF document here A very long.pdf
And renaming files is out of question, for migration purposes, data needs to be retained including the exact filenames and the exact directory path, example:
https://www. domain. com/documents/path/A very long filename of a PDF document here A very long filename of a PDF document here A very long filename of a PDF document here A very long.pdf
When viewed from browser, this will be outputted as:
https://www.domain.com/documents/path/document/20very%20long%20filename%20of%20a%20PDF%20document%20here%20A%20very%20long%20filename%20of%20a%20PDF%20document%20here%20A%20very%20long%20filename%20of%20a%20PDF%20document%20here%20A%20very%20long.pdf
Downloading each file from the browser and saving locally to Windows for transfer to hosting don’t work since Windows truncates (shortens and cuts) long filenames of files, therefore, uploading these same files to server will not have the same files anymore, thus broken links.
Thanks to the URL Decode/Encode online tool, we are able to convert exactly the filename from the URL and rename the files
https://www.urldecoder.org/