Skip to content
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

Add rename option for Response download() #2116

Closed
wants to merge 3 commits into from

Conversation

MGatner
Copy link
Member

@MGatner MGatner commented Aug 1, 2019

Description
Currently an HTTP Response created with download() can take either a path or data with a filename, but when the path option is used the filename is set to the actual local file. This allows an additional parameter for a developer to supply a new name for the file to be downloaded.

Checklist:

  • Securely signed commits
  • Component(s) with PHPdocs
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@MGatner
Copy link
Member Author

MGatner commented Aug 2, 2019

I forgot to update the User Guide on this one. I think with my other PR merged one could actually just load DownloadResponse directly and return it - but since this function exists and is incomplete for standard use scenarios I’ll leave this PR. Let me know if you want anything changed or done differently!

@MGatner
Copy link
Member Author

MGatner commented Aug 12, 2019

@lonnieezell could you weigh in on this when you have a chance? I have a module close to release and it relies on this and #2126. This one can be worked around using DownloadResponse directly but I do think it would be a good addition to Response.

@lonnieezell
Copy link
Member

Sorry - still getting back into the swing after the move. Thanks for the ping.

I'd rather have a new method, setFilename on the DownloadResponse instance. I'm not a fan of adding yet another argument to that method.

That would allow it to work like:

return response()->download($file)->setFilename('foo.pdf');

@MGatner
Copy link
Member Author

MGatner commented Aug 12, 2019

Elegant! I will implement that.

@MGatner
Copy link
Member Author

MGatner commented Aug 12, 2019

Closing in favor of #2129

@MGatner MGatner closed this Aug 12, 2019
@MGatner MGatner deleted the download-rename branch August 26, 2019 02:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants