提交 aa6bcbba 编写于 作者: G George Claghorn

Allow third-party previewers/analyzers to customize their tempdirs

上级 97f317e8
......@@ -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 @@ def download_blob_to(file) # :doc:
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
......@@ -40,8 +40,10 @@ def preview
# 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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册