Active
Project:
File Force Download
Version:
6.x-2.6
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
30 Oct 2013 at 03:41 UTC
Updated:
30 Oct 2013 at 03:41 UTC
When viewing an image via a system path, both the image module and, if so setup, the file force module attempt to send "Content-length" headers.
That would be fine, except they find the file size in slightly different ways.
here's image module's code
function image_file_download($filename) {
$filepath = file_create_path($filename);
$result = db_query("SELECT i.nid, f.filemime, f.filesize FROM {image} i INNER JOIN {files} f ON i.fid = f.fid WHERE f.filepath = '%s'", $filepath);
if ($file = db_fetch_object($result)) {
$node = node_load(array('type' => 'image', 'nid' => $file->nid));
if (node_access('view', $node)) {
// The user either needs to have 'view original images' permission or
// the path must be listed for something other than the node's original
// size. This will be the case when the orignal is smaller than a
// derivative size.
$images = (array) $node->images;
unset($images[IMAGE_ORIGINAL]);
clearstatcache();
if (user_access('view original images') || in_array($filepath, $images)) {
return array(
'Content-Type: ' . mime_header_encode($file->filemime),
'Content-Length: ' . (int) $file->filesize,
);
}
}
return -1;
}
}
for whatever reason, my server returned different values for the filesize as determined by the two modules. Because "image" comes after "file" in the alphabet, the image module's "Content-length" header got sent instead of the (correct) value from file force.
I solved the issue by changing the weight of the file force module using the util module. Might be worth adding this to the install file.