aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/active_file/blob.rb4
-rw-r--r--lib/active_file/site.rb2
-rw-r--r--lib/active_file/site/disk_site.rb6
-rw-r--r--lib/active_file/site/s3_site.rb5
4 files changed, 9 insertions, 8 deletions
diff --git a/lib/active_file/blob.rb b/lib/active_file/blob.rb
index bf34aac794..8a1950c9dc 100644
--- a/lib/active_file/blob.rb
+++ b/lib/active_file/blob.rb
@@ -33,8 +33,8 @@ class ActiveFile::Blob < ActiveRecord::Base
ActiveFile::Filename.new(self[:filename])
end
- def url(expires_in: 5.minutes)
- site.url key, expires_in: expires_in
+ def url(expires_in: 5.minutes, disposition: :inline)
+ site.url key, expires_in: expires_in, disposition: disposition, filename: filename
end
diff --git a/lib/active_file/site.rb b/lib/active_file/site.rb
index fc098e694f..1c71f74f0d 100644
--- a/lib/active_file/site.rb
+++ b/lib/active_file/site.rb
@@ -27,7 +27,7 @@ class ActiveFile::Site
end
- def url(key, expires_in: nil)
+ def url(key, expires_in:, disposition:, filename:)
raise NotImplementedError
end
diff --git a/lib/active_file/site/disk_site.rb b/lib/active_file/site/disk_site.rb
index 3a98971274..ec60175bbf 100644
--- a/lib/active_file/site/disk_site.rb
+++ b/lib/active_file/site/disk_site.rb
@@ -37,13 +37,13 @@ class ActiveFile::Site::DiskSite < ActiveFile::Site
end
- def url(key, expires_in: nil)
+ def url(key, expires_in:, disposition:, filename:)
verified_key_with_expiration = ActiveFile::VerifiedKeyWithExpiration.encode(key, expires_in: expires_in)
if defined?(Rails)
- Rails.application.routes.url_helpers.rails_disk_blob_path(verified_key_with_expiration)
+ Rails.application.routes.url_helpers.rails_disk_blob_path(verified_key_with_expiration, disposition: disposition)
else
- "/rails/blobs/#{verified_key_with_expiration}"
+ "/rails/blobs/#{verified_key_with_expiration}?disposition=#{disposition}"
end
end
diff --git a/lib/active_file/site/s3_site.rb b/lib/active_file/site/s3_site.rb
index e407f84861..cfd2ddcc9a 100644
--- a/lib/active_file/site/s3_site.rb
+++ b/lib/active_file/site/s3_site.rb
@@ -29,8 +29,9 @@ class ActiveFile::Site::S3Site < ActiveFile::Site
end
- def url(key, expires_in: nil)
- object_for(key).presigned_url(:get, expires_in: expires_in)
+ def url(key, expires_in:, disposition:, filename:)
+ object_for(key).presigned_url :get, expires_in: expires_in,
+ response_content_disposition: "#{disposition}; filename=#{filename}"
end
def byte_size(key)