The problem is that current version of Feeds gets the filename from the URL (last part separated by /
without anything after ?
) where the logic is basically (in FeedsParser.inc):
// Strip any query string or fragment from file name.
list($filename) = explode('?', $this->getValue());
list($filename) = explode('#', $filename);
$filename = rawurldecode(drupal_basename($filename));
so it doesn't detect the extension automatically.
So the solution is to patch Feeds by fetching the file name either from headers (Content Disposition, check this patch) or based on its mime type:
$filename = $this->getLocalValue();
$filemime = file_get_mimetype($filename);
if ($filemime != $this->mime_type) {
include_once DRUPAL_ROOT . "/includes/file.mimetypes.inc";
$mapping = file_mimetype_mapping();
if ($ext_id = array_search($this->mime_type, $mapping["mimetypes"])) {
$extensions = array_keys($mapping["extensions"], $ext_id);
foreach ($extensions as $extension) {
if (in_array($extension, explode(' ', $this->allowedExtensions), TRUE)) {
$filename .= ".$extension";
break;
}
}
}
}
Please check the following Drupal issues which have appropriate patches fixing it:
which should be included soon into Feeds.
Alternative solution could be to rename the file before it gets saved.