I came across the following error. When i use the file_entity module to generate a download link to a file the download page uses the following headers:

$headers = array(
    'Content-Type' => 'force-download',
    'Content-Disposition' => 'attachment; filename="' . $file->filename . '"',
    'Content-Length' => $file->filesize,
    'Content-Transfer-Encoding' => 'binary',
    'Pragma' => 'no-cache',
    'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0',
    'Expires' => '0',
    'Accept-Ranges' => 'bytes',
  );

It uses the file objects filename as the download file name. However, the filename is a changeable value. That means that when you change the name and lose the file extension in the name it doesn't give me a correct file for downloading.

I've made a patch that adds the actual file name from the uri instead of the filename. I will create that patch and add it to this issue.

Comments

fabianderijk’s picture

fabianderijk’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 1: file_entity-wrong-filename-when-downloading-2203831-1.patch, failed testing.

fabianderijk’s picture

fabianderijk’s picture

Status: Needs work » Needs review
fabianderijk’s picture

dave reid’s picture

Status: Needs review » Needs work

This should be re-rolled using the following:

drupal_basename($file->uri)
fabianderijk’s picture

Status: Needs work » Needs review
StatusFileSize
new596 bytes

I've changed the patch. It is now using drupal_basename() function.

Status: Needs review » Needs work

The last submitted patch, 8: file_entity-wrong-filename-when-downloading-2203831-8.patch, failed testing.

fabianderijk’s picture

Status: Needs work » Needs review
StatusFileSize
new552 bytes

Status: Needs review » Needs work

The last submitted patch, 10: file_entity-wrong-filename-when-downloading-2203831-10.patch, failed testing.

The last submitted patch, 10: file_entity-wrong-filename-when-downloading-2203831-10.patch, failed testing.

fabianderijk’s picture

StatusFileSize
new553 bytes

Hopefully....

fabianderijk’s picture

Status: Needs work » Needs review
askibinski’s picture

just stumbled upon this bug, patch works like a charm!
Thanks! +1 for getting this in.

aaron’s picture

Version: 7.x-2.0-alpha3 » 7.x-2.x-dev
aaron’s picture

Status: Needs review » Needs work

The last submitted patch, 13: file_entity-wrong-filename-when-downloading-2203831-13.patch, failed testing.

  • Commit 45ddbb7 on 7.x-2.x authored by fabianderijk, committed by Dave Reid:
    Issue #2203831 by fabianderijk: Fixed downloaded filename should be the...
dave reid’s picture

Status: Needs work » Fixed

Committed a modified version to 7.x-2.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.