You are here

function flysystem_file_download in Flysystem 7

Same name and namespace in other branches
  1. 8 flysystem.module \flysystem_file_download()
  2. 3.x flysystem.module \flysystem_file_download()
  3. 2.0.x flysystem.module \flysystem_file_download()
  4. 3.0.x flysystem.module \flysystem_file_download()

Implements hook_file_download().

File

./flysystem.module, line 95
Provides access to various filesystem backends using Flysystem.

Code

function flysystem_file_download($uri) {
  if (!flysystem_dependencies_check()) {
    return;
  }
  $scheme = file_uri_scheme($uri);
  $schemes = variable_get('flysystem', array());
  if (!$scheme || !isset($schemes[$scheme])) {
    return;
  }
  $filesystem = flysystem_factory()
    ->getFilesystem($scheme);
  return array(
    'Content-Type' => file_get_mimetype($uri),
    'Content-Length' => $filesystem
      ->getSize(file_uri_target($uri)),
  );
}