Make download headers customizable #2162
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Requirements
Please take note of our contributing guidelines:
https://laravel-excel-docs.dev/docs/3.0/getting-started/contributinghttps://docs.laravel-excel.com/3.1/getting-started/contributing.htmlFilling out the template is required. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion.
Mark the following tasks as done:
<- will be done as soon as you signal to merge the pull request(done)Description of the Change
Before, CSV downloads would be sent with a mime type of 'text/plain'.
This made Firefox propose to open the file with a text editor instead of LibreOffice / Excel.
This change allows to send custom headers, including ['Content-Type' => 'text/csv'], to fix this pragmatically.
Why Should This Be Added?
text/plain
instead oftext/csv
is a problem, it's most likely a common stake holder request to change the mime typeWith this fix:
Benefits
Shorter code, no need to find a workaround. Will be documented.
Possible Drawbacks
Doesn't break the API. Doesn't change behavior. Custom headers are optional.
Adding another optional parameter might make the API more complex than it needs to be. Maintaining the API with another optional parameter might be harder.
Verification Process
What process did you follow to verify that your change has the desired effects?
Tests.
Running all existing tests.
Applicable Issues
none, afaik.
[Edit]
updated the check mark for "Adjusted the Documentation"