From 85ca1fc15f0ad8ad942ea0c86b7e3d58a747cf80 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Mon, 27 Mar 2017 23:58:17 -0400 Subject: [PATCH] Add examples for pre 3.4.0 Refs #4869 --- en/controllers/request-response.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/en/controllers/request-response.rst b/en/controllers/request-response.rst index 27e837b037..506cc84296 100644 --- a/en/controllers/request-response.rst +++ b/en/controllers/request-response.rst @@ -495,6 +495,13 @@ You can accomplish that by using :php:meth:`Cake\\Http\\Response::withFile()`:: return $response; } + // Prior to 3.4.0 + $file = $this->Attachments->getFile($id); + $this->response->file($file['path']); + // Return the response to prevent controller from trying to render + // a view. + return $this->response; + As shown in the above example, you must pass the file path to the method. CakePHP will send a proper content type header if it's a known file type listed in `Cake\\Http\\Reponse::$_mimeTypes`. You can add new types prior to calling @@ -509,6 +516,12 @@ the browser by specifying the options:: ['download' => true, 'name' => 'foo'] ); + // Prior to 3.4.0 + $this->response->file( + $file['path'], + ['download' => true, 'name' => 'foo'] + ); + The supported options are: name