Thursday, 29 August 2013

CakePHP 1.3 Media view not downloading ZIP file correctly

CakePHP 1.3 Media view not downloading ZIP file correctly

I recently migrated my site from CakePHP 1.1 to 1.3.
I am now using media view to download files, however, I have a major problem.
When I download a zip file through media view, and try to extract it,
windows claims the file is empty.
The file size is correct, same size as on server
I can download the exact same file from the server via FTP, and it is correct
I can download a pdf file through media view, and IT works correctly (but
ZIP files do not)
Here's my controller code:
$this->view = 'Media';
$downloadparams = array(
'id' => 'junkstuff'.'.zip',
'name' => 'junk3',
'download' => true,
'extension' => 'zip', // must be lower case
'path' => APP . 'tmp/files' . DS // don't forget terminal 'DS'
);
$this->set($downloadparams);
Again, if I change to a pdf file, and change 'extension' to 'pdf', it all
works correctly. Debug is set to 0.
My code usage is straight from the 1.3 Cakebook:
http://book.cakephp.org/1.3/en/The-Manual/Developing-with-CakePHP/Views.html
Funny enough, they use zip as an example in the cakebook ....
What might I be doing wrong?
For reference, this thread appears to be the exact same issue, but it has
no answers either: when opened with winrar, Zip file obtained through
Cakephp MediaViews reports Unexpected end of archive

No comments:

Post a Comment