aboutsummaryrefslogtreecommitdiffstats
path: root/lib/active_storage/service
diff options
context:
space:
mode:
Diffstat (limited to 'lib/active_storage/service')
-rw-r--r--lib/active_storage/service/disk_service.rb2
-rw-r--r--lib/active_storage/service/s3_service.rb11
2 files changed, 12 insertions, 1 deletions
diff --git a/lib/active_storage/service/disk_service.rb b/lib/active_storage/service/disk_service.rb
index e2d9191189..87fc06c799 100644
--- a/lib/active_storage/service/disk_service.rb
+++ b/lib/active_storage/service/disk_service.rb
@@ -59,7 +59,7 @@ class ActiveStorage::Service::DiskService < ActiveStorage::Service
if defined?(Rails) && defined?(Rails.application)
Rails.application.routes.url_helpers.rails_disk_blob_path(verified_key_with_expiration, disposition: disposition, filename: filename)
else
- "/rails/blobs/#{verified_key_with_expiration}/#{filename}?disposition=#{disposition}"
+ "/rails/active_storage/disk/#{verified_key_with_expiration}/#{filename}?disposition=#{disposition}"
end
payload[:url] = generated_url
diff --git a/lib/active_storage/service/s3_service.rb b/lib/active_storage/service/s3_service.rb
index 53890751ee..c3b6688bb9 100644
--- a/lib/active_storage/service/s3_service.rb
+++ b/lib/active_storage/service/s3_service.rb
@@ -56,6 +56,17 @@ class ActiveStorage::Service::S3Service < ActiveStorage::Service
end
end
+ def url_for_direct_upload(key, expires_in:, content_type:, content_length:)
+ instrument :url, key do |payload|
+ generated_url = object_for(key).presigned_url :put, expires_in: expires_in,
+ content_type: content_type, content_length: content_length
+
+ payload[:url] = generated_url
+
+ generated_url
+ end
+ end
+
private
def object_for(key)
bucket.object(key)