public function ContentController::downloadExport in Content Synchronization 8
Same name and namespace in other branches
- 8.2 src/Controller/ContentController.php \Drupal\content_sync\Controller\ContentController::downloadExport()
- 3.0.x src/Controller/ContentController.php \Drupal\content_sync\Controller\ContentController::downloadExport()
Downloads a tarball of the site content.
1 string reference to 'ContentController::downloadExport'
File
- src/
Controller/ ContentController.php, line 92
Class
- ContentController
- Returns responses for content module routes.
Namespace
Drupal\content_sync\ControllerCode
public function downloadExport() {
// NOTE: Getting - You are not authorized to access this page.
//$request = new Request(['file' => 'content.tar.gz']);
//return $this->fileDownloadController->download($request, 'temporary');
$filename = 'content.tar.gz';
$file_path = file_directory_temp() . '/' . $filename;
if (file_exists($file_path)) {
unset($_SESSION['content_tar_download_file']);
$mime = \Drupal::service('file.mime_type.guesser')
->guess($file_path);
$headers = array(
'Content-Type' => $mime . '; name="' . Unicode::mimeHeaderEncode(basename($file_path)) . '"',
'Content-Length' => filesize($file_path),
'Content-Disposition' => 'attachment; filename="' . Unicode::mimeHeaderEncode($filename) . '"',
'Cache-Control' => 'private',
);
return new BinaryFileResponse($file_path, 200, $headers);
}
return -1;
}