Lucky::FileResponse
Inherits Lucky::Response < Reference < Object
Return a file's contents for the request.
file can be used to return a file and it's contents to the browser, or
render the contents of the file inline to a web browser. Options for the
method:
path- first argument, required. The path to the file.content_type- defaults to the mime-type that corresponds to the file's extension.disposition- default "attachment" (downloads file), or "inline" (renders file in browser).filename- defaultnil. When overridden and paired withdisposition: "attachment"this will download file with the provided filename.- status -
Int32- the HTTP status code to return with.
Examples:
class Rendering::File < Lucky::Action
get "/file" do
file "spec/fixtures/lucky_logo.png"
end
end
For a plain text file with no extension, have it downloaded with the file named "custom.html" and the content_type "text/html":
class Rendering::File::CustomContentType < Lucky::Action
get "/foo" do
file "spec/fixtures/plain_text",
disposition: "attachment",
filename: "custom.html",
content_type: "text/html"
end
end
Constants
DEFAULT_STATUS = 200
Constructors
Instance methods
content_type
Sourcecontext
Sourcedebug_message
Sourcedisposition
Sourcefilename
Sourceheaders
Sourcepath
Sourceprint
Sourcestatus
Source