Skip to content

Add the possibility to delete file responses after send and set the download filename - #951

Merged
giuscris merged 1 commit into
2.xfrom
feature/file-response-delete-after-send-set-filename
Sep 6, 2026
Merged

giuscris merged 1 commit into
2.xfrom
feature/file-response-delete-after-send-set-filename

Conversation

@giuscris

@giuscris giuscris commented Sep 6, 2026

Copy link
Copy Markdown
Member

This pull request enhances the FileResponse class to provide better control over file downloads and lifecycle management. The main improvements include supporting automatic file deletion after sending and allowing the filename to be set for download responses, while enforcing correct usage with error handling.

File download enhancements:

  • Added a deleteAfterSend property to FileResponse, enabling automatic removal of the file from disk after it is sent to the client. The file is deleted if this property is set to true. [1] [2]
  • Introduced a setFilename method to specify the download filename in the Content-Disposition header. This method throws a LogicException if used when the response is not configured as a download, ensuring correct usage. [1] [2]

Constructor and property improvements:

  • Updated the constructor to accept and set the new deleteAfterSend property, and made download a protected property for better encapsulation.

@giuscris giuscris self-assigned this Sep 6, 2026
@giuscris
giuscris marked this pull request as ready for review September 6, 2026 20:34
@giuscris giuscris added this to the 2.4.0 milestone Sep 6, 2026
@giuscris
giuscris merged commit fdfe504 into 2.x Sep 6, 2026
1 check passed
@giuscris
giuscris deleted the feature/file-response-delete-after-send-set-filename branch September 6, 2026 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant