You are here

function video_upload_v_download in Video 5

Same name and namespace in other branches
  1. 6 types/video_upload/video_upload.module \video_upload_v_download()
  2. 6.2 types/video_upload/video_upload.module \video_upload_v_download()

Implements the hook_v_download

File

types/video_upload/video_upload.module, line 163
Enable Uploaded videos support for video module.

Code

function video_upload_v_download($node) {

  // the code below comes from the audio.module
  // The mime_header_encode function does not (yet) support
  // quoted-string encoding of ASCII strings with special
  // characters.  See discussion at http://drupal.org/node/82614
  $filename = basename($node->current_video_upload_file->filename);

  // If the string contains non-ASCII characters, process it through
  // the mime_header_encode function.
  if (preg_match('/[^\\x20-\\x7E]/', $filename)) {
    $filename = mime_header_encode($filename);
  }
  elseif (preg_match('/[ \\(\\)<>@,;:\\"\\/\\[\\]\\?=]/', $filename)) {
    $filename = '"' . str_replace('"', '\\"', $filename) . '"';
  }
  $headers = array(
    'Content-Type: ' . mime_header_encode($node->current_video_upload_file->filemime),
    'Content-Length: ' . $node->current_video_upload_file->filesize,
    'Content-Disposition: attachment; filename=' . $filename,
  );
  video_upload_file_transfer($node->current_video_upload_file->filepath, $headers);
}