You are here

public function backup_migrate_destination_dropbox::load_file in Backup and Migrate Dropbox 7.2

Same name and namespace in other branches
  1. 7.3 destinations.dropbox.inc \backup_migrate_destination_dropbox::load_file()

Loads the file with the given destination specific id.

Parameters

string $file_id:

Return value

\backup_file The loaded file.

File

./destinations.dropbox.inc, line 60
destinations.dropbox.inc

Class

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

Code

public function load_file($file_id) {
  $file = new backup_file(array(
    'filename' => $file_id,
  ));
  try {
    $path = $this
      ->remote_path($file_id);
    $contents = $this
      ->getDropboxApi()
      ->file_download($path);
    file_put_contents($file
      ->filepath(), $contents);
  } catch (Exception $e) {
    watchdog('backup_migrate', 'Backup Migrate Dropbox Error: ' . $e
      ->getMessage(), array(), WATCHDOG_ERROR);
    drupal_set_message('Backup Migrate Dropbox Error: ' . $e
      ->getMessage(), 'error');
  }
  return $file;
}