[development] hook_fileapi (file products and download permission)

Dave Cohen drupal at dave-cohen.com
Wed May 10 01:19:55 UTC 2006


Thanks for pointing out those modules.  I can see the appeal of filemanager 
and it seems that a module like audio could have saved some trouble by using 

In my thinking, its a great building block.  I'd like to see an even higher 
level model make its way into core.  There should be hooks at both the higher 
and lower levels so third party modules can control what's going on.

To give a concrete example: I want to make an ecommerce product out of an 
audio node.  I want to control download permission based on whether the user 
has purchased the node.  So my logic is a function of the node.  Now 
filemanager has an api to let modules control the download, but its so low 
level that it is not node aware.  So the filemanager_download hook does not 
include the node, and I could not use it for my logic.

So I consider attachment.module to fall into the same category as 
upload.module and audio.module.  Namely, candidates for implementing the APIs 
I described earlier.  (higher level, node aware APIs.  Filemanager would 
invoke it's hook before permitting the download, and attachment would invoke 
the hook I described.)

I have my own wishlist for Drupal file management 
<http://dave-cohen.com/node/1045>.  If I ever get around to implementing it, 
I'll likely use filemanager.module.


On Tuesday 09 May 2006 03:56, Robert Douglass wrote:
> A fileapi hook was proposed nearly 2 years ago, much along the same
> lines. It was concluded, along the way, that the place for this is in
> the file.inc file or in some centralized upload manager. I agree.
> The filemanager[1] module has had the problem of access permissions
> solved for a very long time. It has a hook that lets modules impose
> their own access restrictions on downloads, and supports separate
> public/private download regions (it doesn't force you to choose between
> one or the other). Furthermore, the filemanager module only provides the
> API for uploading and downloading, not the user interface. The UI is
> provided by the attachment module [2]. Other modules (acidfree) have
> decided to use the filemanager module as their basis for dealing with
> uploads. I feel that it is close to what we want in core, and that
> building the proposed fileapi hook would be much easier if this were the
> case.
> If you're not familiar with the filemanager module, please review it.
> I'd be interested in hearing what criticisms exist. I'd be in favor of
> moving it to core.
> cheers,
> Robert
> [1] http://drupal.org/project/filemanager
> [2] http://drupal.org/node/10245

More information about the development mailing list