You are here

function backup_migrate_file_download in Backup and Migrate 5

Same name and namespace in other branches
  1. 6 backup_migrate.module \backup_migrate_file_download()

Implementation of hook_file_download.()

Allow users with the appropriate permissions to download backup files.

1 call to backup_migrate_file_download()
BackupMigrateUnitTest::testFileDownloadHook in tests/BackupMigrateUnitTest.test

File

./backup_migrate.module, line 919
Create (manually or scheduled) and restore backups of your Drupal MySQL database with an option to exclude table data (f.e. cache_*)

Code

function backup_migrate_file_download($path) {
  if (_backup_migrate_path_is_in_save_dir($path)) {
    if (user_access('access backup files') && ($info = _backup_migrate_file_info($path))) {
      return array(
        'Content-Type: ' . $info['filemime'],
        'Content-Length: ' . $info['filesize'],
        'Content-Disposition: attachment; filename="' . $info['filename'] . '"',
      );
    }
    else {
      return -1;
    }
  }
  return NULL;
}