aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/lib/active_storage/downloading.rb
diff options
context:
space:
mode:
authorGeorge Claghorn <george@basecamp.com>2017-11-02 15:07:04 -0400
committerGeorge Claghorn <george@basecamp.com>2017-11-02 15:07:41 -0400
commitaa6bcbbac8517d5b077f21073e9902637d7c7157 (patch)
treee12472825cf46e5458af656564f3bd23814aab08 /activestorage/lib/active_storage/downloading.rb
parent97f317e8ffe823155e37dcdd9ccf3822c3e86f3c (diff)
downloadrails-aa6bcbbac8517d5b077f21073e9902637d7c7157.tar.gz
rails-aa6bcbbac8517d5b077f21073e9902637d7c7157.tar.bz2
rails-aa6bcbbac8517d5b077f21073e9902637d7c7157.zip
Allow third-party previewers/analyzers to customize their tempdirs
Diffstat (limited to 'activestorage/lib/active_storage/downloading.rb')
-rw-r--r--activestorage/lib/active_storage/downloading.rb9
1 files changed, 7 insertions, 2 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