/**
* Download a file from S3 if the file does not exist locally and places it where
* the attachment's file should be.
*
* @param array $s3_object
* @param string $file
*
* @return string|bool File if downloaded, false on failure
*/
protected function copy_s3_file_to_server($s3_object, $file)
{
try {
$this->as3cf->get_s3client($s3_object['region'], true)->getObject(array('Bucket' => $s3_object['bucket'], 'Key' => $s3_object['key'], 'SaveAs' => $file));
} catch (Exception $e) {
error_log(sprintf(__('There was an error attempting to download the file %s from S3: %s', 'as3cf'), $s3_object['key'], $e->getMessage()));
return false;
}
return $file;
}