You are here

private function video_amazon_s3::update_headers in Video 6.5

Same name and namespace in other branches
  1. 6.4 plugins/video_s3/video_s3.lib.inc \video_amazon_s3::update_headers()
1 call to video_amazon_s3::update_headers()
video_amazon_s3::updateAllExpiresHeaders in plugins/video_s3/video_s3.lib.inc
Update Expires headers on currently-uploaded files.

File

plugins/video_s3/video_s3.lib.inc, line 205
Class file to handle amazon s3 transfers.

Class

video_amazon_s3

Code

private function update_headers($file, $permission, $headers) {

  // The video may be stored in the private file store using an absolute path, so remove the first slash if there is one.
  $filepath = ltrim($file->filepath, '/');

  // For old video's (pre-4.5), the filename property is actually the path we need
  if (strpos('/', $file->filename) !== FALSE) {
    $filepath = $file->filename;
  }

  // Reset the Content-Type header usually sent when the S3 library puts a
  // file - we'll lose it otherwise.
  $headers['Content-Type'] = $file->filemime;
  $item = array(
    'bucket' => $file->bucket,
    'filename' => $filepath,
  );
  return $this->s3
    ->copy_object($item, $item, array(
    'acl' => $permission,
    'headers' => $headers,
  ))
    ->isOK();
}