function backup_migrate_destination_files::test_file_readable_remotely in Backup and Migrate 8.2
Same name and namespace in other branches
- 8.3 includes/destinations.file.inc \backup_migrate_destination_files::test_file_readable_remotely()
- 6.3 includes/destinations.file.inc \backup_migrate_destination_files::test_file_readable_remotely()
- 6.2 includes/destinations.file.inc \backup_migrate_destination_files::test_file_readable_remotely()
- 7.3 includes/destinations.file.inc \backup_migrate_destination_files::test_file_readable_remotely()
- 7.2 includes/destinations.file.inc \backup_migrate_destination_files::test_file_readable_remotely()
Check if a file can be read remotely via http.
1 call to backup_migrate_destination_files::test_file_readable_remotely()
- backup_migrate_destination_files::check_web_dir in includes/
destinations.file.inc - Check that a web accessible directory has been properly secured, othewise attempt to secure it.
File
- includes/
destinations.file.inc, line 240 - A destination type for saving locally to the server.
Class
- backup_migrate_destination_files
- A destination type for saving locally to the server.
Code
function test_file_readable_remotely($path, $contents) {
$url = file_create_url($path);
// TODO: Proper checking for absolute paths.
try {
$request = Drupal::httpClient()
->get($url);
$response = $request
->send();
// Expected result.
if (!empty($result->data) && strpos($result->data, $contents) !== FALSE) {
return TRUE;
}
} catch (Exception $e) {
return FALSE;
}
return FALSE;
}