Add support for on-disk file streaming.
This commit is contained in:
+5
-1
@@ -403,9 +403,13 @@ module Precious
|
|||||||
@bar_side = wiki.bar_side
|
@bar_side = wiki.bar_side
|
||||||
|
|
||||||
mustache :page
|
mustache :page
|
||||||
elsif file = wiki.file(fullpath)
|
elsif file = wiki.file(fullpath, wiki.ref, true)
|
||||||
|
if file.on_disk?
|
||||||
|
send_file file.on_disk_path, :disposition => 'inline'
|
||||||
|
else
|
||||||
content_type file.mime_type
|
content_type file.mime_type
|
||||||
file.raw_data
|
file.raw_data
|
||||||
|
end
|
||||||
else
|
else
|
||||||
page_path = [path, name].compact.join('/')
|
page_path = [path, name].compact.join('/')
|
||||||
redirect to("/create/#{clean_url(encodeURIComponent(page_path))}")
|
redirect to("/create/#{clean_url(encodeURIComponent(page_path))}")
|
||||||
|
|||||||
@@ -578,6 +578,12 @@ context "Frontend with lotr" do
|
|||||||
assert_match /Bilbo Baggins/, last_response.body
|
assert_match /Bilbo Baggins/, last_response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "streaming files to browser" do
|
||||||
|
get "/Data.csv"
|
||||||
|
assert last_response.ok?
|
||||||
|
assert last_response.headers.include? 'Content-Disposition'
|
||||||
|
end
|
||||||
|
|
||||||
# base path requires 'map' in a config.ru to work correctly.
|
# base path requires 'map' in a config.ru to work correctly.
|
||||||
test "create pages within sub-directories using base path" do
|
test "create pages within sub-directories using base path" do
|
||||||
Precious::App.set(:wiki_options, { :base_path => 'wiki' })
|
Precious::App.set(:wiki_options, { :base_path => 'wiki' })
|
||||||
|
|||||||
Reference in New Issue
Block a user