1

I have a D7 site that includes a few hundred nodes that have PDF attachments that use the core file field and the private file system. The site uses a custom module to dynamically watermark these PDFs and we're going through an update that requires each PDF to be updated to use a new layout.

In order to minimize downtime, what I was hoping to do was pull the site to a development environment, directly edit the PDFs that are stored in the private file system and then push the updated files and changes to the watermarking feature back to production.

All seemed like a good plan, but I'm finding that Drupal will no longer serve the updated files after they've been modified. No error messages in the logs (Drupal, PHP or server) and the site just times out when you request new files from /system/files/...

I haven't been able to find any documentation or relevant issues on the subject, but I'm wondering if Drupal's private file system is failing to deliver the file due to changes to the timestamp or file size?

Has anyone run into this before? I'm hoping there's a workaround that does not require that we update hundreds of nodes by editing and manually re-uploading each file one at a time.

Thanks much!

  • 2
    Are the permissions correct after you've re-uploaded the files? – Clive Dec 18 '13 at 19:45
0

The files won't be served if the entry in the file_managed table for that file does not have the correct filesize.

  • Please stop including your opinions about how bad Drupal is in your answers. You don't like it, we get it. – Clive Dec 23 '13 at 17:28
  • That explains why it won't serve them. Anybody know of a workaround? – BBC Mar 28 '14 at 13:44
0

There are a few problems with storing very large (>2GB) files in Drupal using the private file system.

  1. The filesize column doesn't allow recording values this large (https://www.adammalone.net/post/dealing-large-filesizes-drupal#.VtuIZjYc7AV)
  2. If you attempt to upload a small placeholder file, and then replace it with the larger file, you will have the problem that @Drupal-Hater refers to.

The first problem has a fix in the link I provided.

An approach to resolving the second problem is:

function hook_file_download($uri) {

  // Get file length
  $length = filesize($uri);

  // Set timeout to unlimited for this request 
  // (could do this conditionally for larger files only)
  drupal_set_time_limit(0);

  // Return length
  return array('Content-Length' => $length);

}

This will mean a performance hit for any privately hosted files. A better approach would probably be to store the file length in the file_managed table. However, it's up to you to decide when you should do this, maybe when the node is being viewed/edited? The approach I've listed above works and the perf hit is minimal - hard to notice at all and shouldn't be a problem if you use private files selectively.

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.