You are here

function hook_commerce_file_content_headers_alter in Commerce File 7

Allows other modules to alter the returned headers for a Commerce File.

Parameters

$headers: An associative array of headers, as expected by file_transfer().

$file: A file object.

1 invocation of hook_commerce_file_content_headers_alter()
commerce_file_get_content_headers in ./commerce_file.module
Returns appropriate content headers for download

File

./commerce_file.api.php, line 186
Hooks provided by the Commerce File module.

Code

function hook_commerce_file_content_headers_alter(&$headers, $file) {
  $name = mime_header_encode($file->filename);

  // force a download for all files
  $headers = array(
    'Content-Disposition' => 'attachment; filename="' . $name . '"',
  ) + $headers;
}