-
Notifications
You must be signed in to change notification settings - Fork 10.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Outputting file content with headers won't work #2079
Comments
I think you should use
Give that a shot, I have done something similar to return encrypted audio files where I had to unencrypt the file contents first. |
That worked flawlessly, thank you very much. I was not aware of the |
Yeah, it is not in the documents. If you dig around in the code ( as I tend to do ) there are plenty of things not clearly documented. Perhaps this section of the docs needs to be updated. http://laravel.com/docs/responses#special-responses to include how to stream file content. |
Here is the StreamedResponse documentation in case you need more details. |
@xmarcos thanks, |
Scenario: web service where users can upload their photos. Pictures are stored under /app/storage/ (i.e. not /public/). Direct access to the images is not allowed because some database stuff needs to be done before outputting the actual image.
How it works:
All the arguments have been checked and returns the correct values (including $mime, which has been set before).
4. It won't work. For some reason, the size from File::size() is correct and the Content-Length is using that exact value, but the actual amount of data sent to the output is a bit smaller (browser will complain about not getting all the promised content).
How I tried to fix it:
Headers using header():
Headers using Response object (content = different data):
The only difference is that couple headers, which obviously is not the problem (I even tried to send the exact same ones using header() and the output was correct). The underlying cause could be something related with the session management, but I did not found any way to disable sessions for one specific route (which would not be a practical thing, but just for testing).
The text was updated successfully, but these errors were encountered: