Thursday, October 24, 2013

File clean up after using CakeResponse::file()

I have a function that extracts a file from an archive, and streams it to the client via CakeResponse::file().

As a part of extracting the file from the archive, I've had to put it in a temporary file, and then pass that to CakeResponse::file().

Once this is done, I'd like to clean up the temporary file, however, I'm having trouble finding a good place to do it.

Currently, I'm setting a property on the controller so that I can work out what file I have to remove later.

I've tried using afterFilter on the controller, but this seems to remove the file before it starts getting streamed to the user.

The next spot might be in a Dispatch filter, but I've got no idea where to start, and if a dispatch filter has access to the controller.

Any pointers, please?

Regards
Reuben Helms

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: