aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/lib/active_storage/downloader.rb
diff options
context:
space:
mode:
authorGeorge Claghorn <george@basecamp.com>2018-05-17 19:14:11 -0400
committerGeorge Claghorn <george@basecamp.com>2018-05-17 19:14:11 -0400
commit9f95767979579f5761cb0d2bcccb67f3662349c5 (patch)
tree9375eeeeff7d494e2dcf0b206e89ea892cb21f4a /activestorage/lib/active_storage/downloader.rb
parentf018d4e118f34fd9b54ad45771ed575936678158 (diff)
downloadrails-9f95767979579f5761cb0d2bcccb67f3662349c5.tar.gz
rails-9f95767979579f5761cb0d2bcccb67f3662349c5.tar.bz2
rails-9f95767979579f5761cb0d2bcccb67f3662349c5.zip
Permit opening a blob in a custom tempdir
Diffstat (limited to 'activestorage/lib/active_storage/downloader.rb')
-rw-r--r--activestorage/lib/active_storage/downloader.rb11
1 files changed, 6 insertions, 5 deletions
diff --git a/activestorage/lib/active_storage/downloader.rb b/activestorage/lib/active_storage/downloader.rb
index 7f5b4936a5..0e7039e104 100644
--- a/activestorage/lib/active_storage/downloader.rb
+++ b/activestorage/lib/active_storage/downloader.rb
@@ -1,9 +1,10 @@
# frozen_string_literal: true
module ActiveStorage
- class Downloader
- def initialize(blob)
- @blob = blob
+ class Downloader #:nodoc:
+ def initialize(blob, tempdir: nil)
+ @blob = blob
+ @tempdir = tempdir
end
def download_blob_to_tempfile
@@ -14,10 +15,10 @@ module ActiveStorage
end
private
- attr_reader :blob
+ attr_reader :blob, :tempdir
def open_tempfile
- file = Tempfile.open([ "ActiveStorage", tempfile_extension_with_delimiter ])
+ file = Tempfile.open([ "ActiveStorage", tempfile_extension_with_delimiter ], tempdir)
begin
yield file