3

I'm trying to protect (in this example) audio files from being downloaded. I'm currently using jPlayer because it is supposed to provide download protection (which it supposedly does, but it breaks when I enable it).
Surely there is a way to prevent leeching and downloading of files. The Drupal private file system, as I understand it, only restricts access per user role. Creating a path system/files/file.mp3. Which tells Drupal to check if the user has permission to download the file. So if I set that up - with the file storage outside my public root - when i type http://site.com/system/files/file.mp3, Drupal just serves up the file and it starts downloading. Its a public file system by default, the audio file is a private file field. If I turn on protection in the jPlayer module then it wont play.

In the reports, immediately when viewing the node that the audio is on I get that the file cannot be accessed - twice in a row. Clicking on play gets me this:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1-30-1318255859' for key 'PRIMARY': INSERT INTO {jplayer_denied} (uid, fid, hostname, timestamp) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3); Array ( [:db_insert_placeholder_0] => 1 [:db_insert_placeholder_1] => 30 [:db_insert_placeholder_2] => {my ip address here} [:db_insert_placeholder_3] => 1318255859 ) in drupal_write_record() (line 6868 of /var/www/html/drupal/includes/common.inc).

Can anyone steer me in the right direction here?

EDIT:

Well I finally got the private serving working actually - kind of. It will serve up the file once when the page is first loaded and will only serve it again if I almost immediately try and hit the URL again. Then after a couple seconds it will block it like it's supposed to. This works good enough for now I suppose.

1

For a real good private file protection use the Private Files module.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.