2

I have an issue with FireFox where it can't download generated private file PDFs, yet Chrome has no such issue.

We populate PDF files with TCPDF and they get moved and copied into a few different directories. But ultimately, they're in directories in the private files directory behind the document root, with Drupal configured to look at this directory.

If I move any of these PDFs into the root of the site and access them directly with the URL, it works fine, but I wouldn't rule out the PDFs being corrupted in some small way. I've looked at the response headers when the file's downloading and all is in order, until I get this NS_ERROR_NET_PARTIAL_TRANSFER message and it fails.

I've run with xdebug enabled and stepped through hook functions of hook_file_download and the headers generated there all seem ok too.

Other private PDFs that aren't generated can be downloaded no problem.

I'm really running out of ideas of what it could be regarding FireFox and the private files system.

2
  • 1
    Just a shot into the blue: Have you checked HTTP response headers? Esp. content-length and Transfer-Encoding ? - Further read daniel.haxx.se/blog/2015/02/12/…
    – Hudri
    Dec 5, 2018 at 13:22
  • You were correct regarding the Content-Length header! I just spotted that it's consistently larger in the header than the actual file's size! When we edit the value of filesize in the file_managed table to the value specified on the server, it works perfectly. So I have another issue in how Drupal saves the files initially. Thanks v much! Dec 5, 2018 at 16:20

1 Answer 1

2

Hudri's comment ultimately led me to the answer, so huge thanks!

The real issue is the mismatch between the file's real size on the server and the size Drupal stores in the file_managed table, filesize column. Firefox will only download files that have matching values for the HTTP response's Content-Length header and the real length of the file sent to the browser. As to why the value's greater than the real one I'm still finding the answer to.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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