{"action":"created","issue":{"url":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues/3388","labels_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues/3388/labels{/name}","comments_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues/3388/comments","events_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues/3388/events","html_url":"https://github.com/silverstripe/silverstripe-framework/issues/3388","id":40254327,"number":3388,"title":"No way to send or stream large files without increasing memory","user":{"login":"dhensby","id":563596,"avatar_url":"https://avatars.githubusercontent.com/u/563596?v=3","gravatar_id":"","url":"https://api.github.com/users/dhensby","html_url":"https://github.com/dhensby","followers_url":"https://api.github.com/users/dhensby/followers","following_url":"https://api.github.com/users/dhensby/following{/other_user}","gists_url":"https://api.github.com/users/dhensby/gists{/gist_id}","starred_url":"https://api.github.com/users/dhensby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dhensby/subscriptions","organizations_url":"https://api.github.com/users/dhensby/orgs","repos_url":"https://api.github.com/users/dhensby/repos","events_url":"https://api.github.com/users/dhensby/events{/privacy}","received_events_url":"https://api.github.com/users/dhensby/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/silverstripe/silverstripe-framework/labels/type/enhancement","name":"type/enhancement","color":"02e10c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2014-08-14T13:35:20Z","updated_at":"2016-01-05T00:12:27Z","closed_at":null,"body":"When sending files to the browser using `SS_HTTPRequest::send_file()` the entire file is loaded into memory, stored on the response object and passed to the controller.\r\n\r\nThis means that the script needs access to as much memory as the file takes to store. This can cause PHP to error if the file is larger than the memory limit and crash a server if larger than the available memory. In fact, I suspect because output buffering is used, that twice as much memory is needed.\r\n\r\nOne way to do this \"normally\" with PHP is to send the file in chunks (open the file for reading and send it in 1MB chunks for example)\r\n\r\nOne way to resolve this could be to allow the `SS_HTTPResponse::setBody()` to accept callbacks so that a function can be used to stream the response to the browser rather than having the response body stored in memory."},"comment":{"url":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues/comments/168850951","html_url":"https://github.com/silverstripe/silverstripe-framework/issues/3388#issuecomment-168850951","issue_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues/3388","id":168850951,"user":{"login":"tractorcow","id":936064,"avatar_url":"https://avatars.githubusercontent.com/u/936064?v=3","gravatar_id":"","url":"https://api.github.com/users/tractorcow","html_url":"https://github.com/tractorcow","followers_url":"https://api.github.com/users/tractorcow/followers","following_url":"https://api.github.com/users/tractorcow/following{/other_user}","gists_url":"https://api.github.com/users/tractorcow/gists{/gist_id}","starred_url":"https://api.github.com/users/tractorcow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tractorcow/subscriptions","organizations_url":"https://api.github.com/users/tractorcow/orgs","repos_url":"https://api.github.com/users/tractorcow/repos","events_url":"https://api.github.com/users/tractorcow/events{/privacy}","received_events_url":"https://api.github.com/users/tractorcow/received_events","type":"User","site_admin":false},"created_at":"2016-01-05T00:12:27Z","updated_at":"2016-01-05T00:12:27Z","body":"We are looking at implementing a new feature for serving secure assets, but it will be available for any streaming content."}}