Class: RubstApi::FileResponse
- Inherits:
-
StreamingResponse
- Object
- Response
- StreamingResponse
- RubstApi::FileResponse
- Defined in:
- lib/rubst_api/responses.rb
Instance Attribute Summary
Attributes inherited from Response
#body, #headers, #media_type, #status_code
Instance Method Summary collapse
-
#initialize(path, filename: nil, media_type: "application/octet-stream", **options) ⇒ FileResponse
constructor
A new instance of FileResponse.
Methods inherited from StreamingResponse
Methods inherited from Response
#delete_cookie, #finish, #render, #set_cookie
Constructor Details
#initialize(path, filename: nil, media_type: "application/octet-stream", **options) ⇒ FileResponse
Returns a new instance of FileResponse.
52 53 54 55 56 |
# File 'lib/rubst_api/responses.rb', line 52 def initialize(path, filename: nil, media_type: "application/octet-stream", **) headers = .delete(:headers) || {} headers["content-disposition"] = %(attachment; filename="#{filename}") if filename super(File.open(path, "rb"), media_type:, headers:, **) end |