aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activestorage/lib/active_storage/downloading.rb9
-rw-r--r--activestorage/lib/active_storage/previewer.rb4
2 files changed, 10 insertions, 3 deletions
diff --git a/activestorage/lib/active_storage/downloading.rb b/activestorage/lib/active_storage/downloading.rb
index ceb7cce0c7..3dac6b116a 100644
--- a/activestorage/lib/active_storage/downloading.rb
+++ b/activestorage/lib/active_storage/downloading.rb
@@ -3,9 +3,9 @@
module ActiveStorage
module Downloading
private
- # Opens a new tempfile and copies blob data into it. Yields the tempfile.
+ # Opens a new tempfile in #tempdir and copies blob data into it. Yields the tempfile.
def download_blob_to_tempfile # :doc:
- Tempfile.open("ActiveStorage") do |file|
+ Tempfile.open("ActiveStorage", tempdir) do |file|
download_blob_to file
yield file
end
@@ -17,5 +17,10 @@ module ActiveStorage
blob.download { |chunk| file.write(chunk) }
file.rewind
end
+
+ # Returns the directory in which tempfiles should be opened. Defaults to +Dir.tmpdir+.
+ def tempdir # :doc:
+ Dir.tmpdir
+ end
end
end
diff --git a/activestorage/lib/active_storage/previewer.rb b/activestorage/lib/active_storage/previewer.rb
index 460f6d5678..ed75bae3b5 100644
--- a/activestorage/lib/active_storage/previewer.rb
+++ b/activestorage/lib/active_storage/previewer.rb
@@ -40,8 +40,10 @@ module ActiveStorage
# end
# end
# end
+ #
+ # The output tempfile is opened in the directory returned by ActiveStorage::Downloading#tempdir.
def draw(*argv) # :doc:
- Tempfile.open("ActiveStorage") do |file|
+ Tempfile.open("ActiveStorage", tempdir) do |file|
capture(*argv, to: file)
yield file
end