aboutsummaryrefslogtreecommitdiffstats
path: root/lib/active_storage/service/s3_service.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/active_storage/service/s3_service.rb')
-rw-r--r--lib/active_storage/service/s3_service.rb11
1 files changed, 11 insertions, 0 deletions
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)