https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44272 --- Comment #5 from Nick Clemens (kidclamp) <nick@bywatersolutions.com> --- Created attachment 212580 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=212580&action=edit Bug 44272: Add readable links for uploaded files Uploaded files are currently linked as OPACBaseURL/cgi-bin/koha/opac-retrieve-file.pl?id=<hashvalue> This patch also accepts, and generates, links in the form OPACBaseURL/cgi-bin/koha/opac-retrieve-file.pl/<hashvalue>/<filename> The file is still served by opac-retrieve-file.pl, so the public flag and the Content-Type/Content-Disposition headers still apply. The filename must match the upload exactly: a different or missing filename, or any other path, returns 404 Not Found. Existing ?id= links keep working. A missing or non-public file now returns a 404 status instead of 200. - opac-retrieve-file.pl reads <hashvalue>/<filename> from PATH_INFO - Koha::UploadedFile->looks_like_hashvalue recognises a hashvalue: MD5, or SHA-1 for uploads made before Koha 3.22 - Koha::UploadedFile->opac_url builds the readable link. It is already URI-escaped (including OPACBaseURL), so the template outputs it with $raw: the url filter would escape it a second time (%20 -> %2520) - Tools > Upload and the cataloguing plugin (upload.pl) use opac_url - C4::HTML5Media recognises both link forms Test plan: 1. Apply patch, restart_all 2. prove t/db_dependent/Upload.t 3. Tools > Upload: upload a file with 'Allow public downloads' checked 4. Click the 'Yes' link in the Public column: the URL now ends in /opac-retrieve-file.pl/<hash>/<filename> and the file downloads 5. Replace the URL with the old ?id=<hash> form: still works 6. Change the filename at the end of the URL, or remove it: 404 7. Upload a non-public file and try its readable URL in the OPAC: 404 8. Link the upload.pl plugin to 856$u, edit a record, open the plugin, search for your file and click Choose: 856$u gets the readable URL 9. Enable HTML5MediaEnable, upload an mp3/mp4 publicly, put the readable URL in 856$u and confirm the player appears on the OPAC detail page Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> -- You are receiving this mail because: You are watching all bug changes.