function backup_migrate_destination_dropbox::save_file in Backup and Migrate Dropbox 6.2
Same name and namespace in other branches
- 6 destinations.dropbox.inc \backup_migrate_destination_dropbox::save_file()
- 7.3 destinations.dropbox.inc \backup_migrate_destination_dropbox::save_file()
- 7 destinations.dropbox.inc \backup_migrate_destination_dropbox::save_file()
- 7.2 destinations.dropbox.inc \backup_migrate_destination_dropbox::save_file()
Save to to the Dropbox destination.
File
- ./
destinations.dropbox.inc, line 21 - Functions to handle the dropbox backup destination.
Class
- backup_migrate_destination_dropbox
- A destination for sending database backups to a Dropbox account.
Code
function save_file($file, $settings) {
$dropbox = $this
->dropbox_object();
$destination = $this->dest_url['path'];
if ('/' != $destination[0]) {
$destination = '/' . $destination;
}
$dest_filename = realpath(variable_get('file_directory_temp', '')) . '/' . $file->file_info['filename'] . '.' . implode('.', $file->ext);
rename($file
->filepath(), $dest_filename);
try {
$dropbox
->upload($dest_filename, $destination);
} catch (Exception $e) {
watchdog('backup_migrate', 'There was a problem when we tried to save the file to Dropbox, the error message was: !error', array(
'!error' => $e
->getMessage(),
), WATCHDOG_ERROR);
return FALSE;
}
return $file;
}