Pass thru feature added to download helper #365

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
4 participants

A small additional feature has been added to the download helper so that you can pass thru a file to the output. This method has better performance. All original functionality remains and is backwards compatible.

@netcore2k netcore2k A small additional feature has been added to the download helper so t…
…hat you can pass thru a file to the output. This method has better performance. All original functionality remains and is backwards compatible.
45ab0b8

Inside PHP the readfile() method will attempt to memory map the file and do direct copy to output stream. If for whatever reason it cannot be memory mapped. For instance if the file is larger than what PHP can allocate it will buffer smaller amounts and push it through that way. Still never once using PHP objects only native C/C++.

Contributor

derekjones commented Sep 1, 2011

Without exit()ing after pushing the file, don't you stand the chance that the application will continue to output content, resulting in a malformed file?

Correct. I also noticed another issue. Sorry, this is what I get for reworking the code to CI standards at 4am. I'll make the corrections.

I have some other changes to CI that would benefit others. Things like SSL for the xmlrpc library, other misc SSL support. I will gather them all together tomorrow and commit them all at once and send another pull request.

Contributor

it-can commented Sep 2, 2011

Wil this also work with large files? Without memory problems?

Yes. As mentioned above if it can't memory map the while file into memory it will push it in smaller chunks to the browser.

I'm making further changes to take advantage of mod_xsendfile module for apache, which means less overhead for sending REALLY large files. By using the http "X-Sendfile:" response header. The module the pipes the file directly from apache after the PHP instance has finished.

netcore2k closed this Sep 6, 2011

netcore2k reopened this Sep 6, 2011

Contributor

it-can commented Sep 6, 2011

Also for xsendfile for nginx?

Sure I'll add support for nginx it simple uses the X-Accel-Redirect header instead.

Contributor

it-can commented Sep 6, 2011

Cool

@narfbg narfbg added a commit that referenced this pull request Nov 22, 2012

@narfbg narfbg Added support for stream-like downloads of existing files to force_do…
…wnload()

Based on code/ideas from PR #365, #1254
53fff91
Contributor

narfbg commented Nov 22, 2012

Implemented, see the above commit.

narfbg closed this Nov 22, 2012

@nonchip nonchip pushed a commit to nonchip/CodeIgniter that referenced this pull request Jun 29, 2013

@narfbg narfbg Added support for stream-like downloads of existing files to force_do…
…wnload()

Based on code/ideas from PR #365, #1254
13d317f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment