You are here

function backup_migrate_destination_s3_compatible::_save_file in Backup and Migrate S3 7

Save to to the s3 destination.

File

./destinations.s3.inc, line 124
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 _save_file($file, $settings) {
  $this
    ->s3_init();
  $options = array();
  if (!empty($this->settings['s3_min_part_size'])) {
    $options['min_part_size'] = $this->settings['s3_min_part_size'] * 1024 * 1024;
  }
  try {
    $this->s3
      ->upload($this
      ->s3_bucket(), $this
      ->s3_path($file
      ->filename()), fopen($file
      ->filepath(), 'r'), 'private', $options);
  } catch (S3Exception $e) {
    $e_msg = 'S3 error saving %file - %code %error';
    $e_args = array(
      '%file' => $file
        ->filename(),
      '%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);
  } catch (MultipartUploadException $e) {
    $e_msg = 'S3 error saving %file - %code %error';
    $e_args = array(
      '%file' => $file
        ->filename(),
      '%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;
}