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/gcs_service.rb2
-rw-r--r--lib/active_storage/service/mirror_service.rb6
-rw-r--r--lib/active_storage/service/s3_service.rb2
4 files changed, 12 insertions, 0 deletions
diff --git a/lib/active_storage/service/disk_service.rb b/lib/active_storage/service/disk_service.rb
index 3cde203a31..7e2079385f 100644
--- a/lib/active_storage/service/disk_service.rb
+++ b/lib/active_storage/service/disk_service.rb
@@ -3,6 +3,8 @@ require "pathname"
require "digest/md5"
require "active_support/core_ext/numeric/bytes"
+# Wraps a local disk path as a Active Storage service. See `ActiveStorage::Service` for the generic API
+# documentation that applies to all services.
class ActiveStorage::Service::DiskService < ActiveStorage::Service
attr_reader :root
diff --git a/lib/active_storage/service/gcs_service.rb b/lib/active_storage/service/gcs_service.rb
index 4632e5f820..d681a3dc45 100644
--- a/lib/active_storage/service/gcs_service.rb
+++ b/lib/active_storage/service/gcs_service.rb
@@ -1,6 +1,8 @@
require "google/cloud/storage"
require "active_support/core_ext/object/to_query"
+# Wraps the Google Cloud Storage as a Active Storage service. See `ActiveStorage::Service` for the generic API
+# documentation that applies to all services.
class ActiveStorage::Service::GCSService < ActiveStorage::Service
attr_reader :client, :bucket
diff --git a/lib/active_storage/service/mirror_service.rb b/lib/active_storage/service/mirror_service.rb
index 54465cad05..7c407f2730 100644
--- a/lib/active_storage/service/mirror_service.rb
+++ b/lib/active_storage/service/mirror_service.rb
@@ -1,5 +1,8 @@
require "active_support/core_ext/module/delegation"
+# Wraps a set of mirror services and provides a single `ActiveStorage::Service` object that will all
+# have the files uploaded to them. A `primary` service is designated to answer calls to `download`, `exists?`,
+# and `url`.
class ActiveStorage::Service::MirrorService < ActiveStorage::Service
attr_reader :primary, :mirrors
@@ -16,12 +19,15 @@ class ActiveStorage::Service::MirrorService < ActiveStorage::Service
@primary, @mirrors = primary, mirrors
end
+ # Upload the `io` to the `key` specified to all services. If a `checksum` is provided, all services will
+ # ensure a match when the upload has completed or raise an `ActiveStorage::IntegrityError`.
def upload(key, io, checksum: nil)
each_service.collect do |service|
service.upload key, io.tap(&:rewind), checksum: checksum
end
end
+ # Delete the file at the `key` on all services.
def delete(key)
perform_across_services :delete, key
end
diff --git a/lib/active_storage/service/s3_service.rb b/lib/active_storage/service/s3_service.rb
index 72ff9f3f36..c21977044d 100644
--- a/lib/active_storage/service/s3_service.rb
+++ b/lib/active_storage/service/s3_service.rb
@@ -1,6 +1,8 @@
require "aws-sdk"
require "active_support/core_ext/numeric/bytes"
+# Wraps the Amazon Simple Storage Service (S3) as a Active Storage service.
+# See `ActiveStorage::Service` for the generic API documentation that applies to all services.
class ActiveStorage::Service::S3Service < ActiveStorage::Service
attr_reader :client, :bucket, :upload_options