You are here

flysystem.module in Flysystem 8

Provides access to various filesystem backends using Flysystem.

File

flysystem.module
View source
<?php

/**
 * @file
 * Provides access to various filesystem backends using Flysystem.
 */

/**
 * Implements hook_cron().
 */
function flysystem_cron() {
  Drupal::service('flysystem_factory')
    ->ensure();
}

/**
 * Implements hook_rebuild().
 */
function flysystem_rebuild() {
  Drupal::service('flysystem_factory')
    ->ensure();
}

/**
 * Implements hook_file_download().
 */
function flysystem_file_download($uri) {
  $schemes = Drupal::service('flysystem_factory')
    ->getSchemes();
  $scheme = Drupal::service('file_system')
    ->uriScheme($uri);
  if (!$scheme || !in_array($scheme, $schemes, TRUE)) {
    return;
  }
  return [
    'Content-Type' => Drupal::service('file.mime_type.guesser.extension')
      ->guess($uri),
    'Content-Length' => filesize($uri),
  ];
}

Functions