Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
It would be really nice if Drupal had the ability to notify other modules when a private file was finished transferring so things could be done such as marking the file as already downloaded so it couldn't be downloaded again. The best you can do currently is stick this logic in hook_file_download(), but if the file fails to transfer for whatever reason, it will get erroneously marked as downloaded when it's not. Angry e-mails ensue.
As a workaround, I had to copy/paste/rename file_transfer() into my custom module and add my download-checking logic just before exit(); which is pretty meh.
Comments
Comment #1
Damien Tournoud CreditAttribution: Damien Tournoud commentedI wonder how that could play with fast private transfers we could implement using
X-Sendfile
headers. I'm not sure we have the information "the transfer succeeded" in that case.Comment #2
drewish CreditAttribution: drewish commentedsounds similar to #233997: New hook triggered on file download
Comment #3
webchickIt does indeed!