|
WorkingWithLargeFiles
dealing with large file up and downloads
Using streamsIn order to allow transfers of big files, SabreDAV makes use of streams everywhere internally. This allows you to deal with very large files (I've tried up to 2GB up/down), without requiring a high number for memory_limit. Basically this means you should use fopen() whenever you open files through a get method: ...
function get() {
return fopen('file','r');
}
createFile() and put() also get open streams as arguments. You can safely use file_put_contents here, because if it encounters a stream as it's second argument it will work as stream_copy_to_stream. If you intend to do pre or post-processing within php, you should use temporary files and process it in for example 2M chunks (or lower/higher?). Better yet, use the php://temp stream. This special stream handler keeps the entire file into memory, but will switch to disk if the file exceeds 2MB. Basic Digest caveatThe standard Basic Digest class will advertise support for integrity checking. This means it will run an md5 on the entire request body and need the entire memory in file. Although most clients I've seen don't actually use this, there could be a few out there that do. In the future there will a setting to turn it off, and it will be optimized for large files. |
Sign in to add a comment