views:

100

answers:

2

How do I serve files in Drupal without revealing a link that might be re-used? This sort of thing is usually handled by postbacks in .NET for example, but I can't find any documentation for accomplishing it in Drupal.

The goal is to be able to give a specific file to a user exactly once when they complete a series of steps defined by the module. Some of the eCommerce modules provide some features to support limited file downloads, but I would prefer not to install an entire eCommerce solution just to accomplish one task.

Thanks in advance!

A: 

You can do it at the web server level, saving on the drupal code+db load: for example with lighttpd you can use the mod-trigger-b4-dl module to have limited validity urls, either using an interstitial or a validation callback in drupal.

See mod trigger b4 dl docs for details

FGM
Interesting -- thanks! Is there an equivalent feature in Apache that you know of?
anschauung
It could well be a lighttpd exclusive, I'm afraid. Note that it's not difficult to combine both servers.
FGM
+1  A: 

You would write a module to manage the one-time URLs and log when they have been accessed.

The module would use the PHP fread() function to serve the file from some private location.

Ben Hammond
I put together a little proof of concept based on your suggestion, and things are working like a charm so far. Thanks!
anschauung