You are here

function backup_migrate_destination_s3_compatible::load_file in Backup and Migrate S3 7

Load from the s3 destination.

File

./destinations.s3.inc, line 161
Functions to handle the dropbox backup destination.

Class

backup_migrate_destination_s3_compatible
A destination for sending database backups to a Dropbox account.

Code

function load_file($file_id) {
  backup_migrate_include('files');
  $file = new backup_file(array(
    'filename' => $file_id,
  ));
  $this
    ->s3_init();
  try {
    $this->s3
      ->getObject(array(
      'Bucket' => $this
        ->s3_bucket(),
      'Key' => $this
        ->s3_path($file
        ->filename()),
      'SaveAs' => $file
        ->filepath(),
    ));
  } catch (S3Exception $e) {
    $e_msg = 'S3 error loading %file - %code %error';
    $e_args = array(
      '%file' => $file_id,
      '%error' => $e
        ->getMessage(),
      '%code' => $e
        ->getAwsErrorCode(),
    );
    drupal_set_message(t($e_msg, $e_args), 'error');
    watchdog('backup_migrate_s3', $e_msg, $e_args, WATCHDOG_ERROR);
  }
  return $file;
}