class ActiveStorage::Service::BetterS3Service

Adds handling of path-prefixes to S3 Adapted from: github.com/rails/rails/issues/32790

Attributes

bucket[R]
client[R]
root[R]
upload_options[R]

Public Class Methods

new(bucket:, upload: {}, **options) click to toggle source
Calls superclass method
# File lib/generators/rockstart/storage/active_storage/templates/better_s3_service.rb, line 14
def initialize(bucket:, upload: {}, **options)
  @root = options.delete(:root)
  super(bucket: bucket, upload: upload, **options)
end

Private Instance Methods

object_for(key) click to toggle source
# File lib/generators/rockstart/storage/active_storage/templates/better_s3_service.rb, line 21
def object_for(key)
  path = root.present? ? File.join(root, key) : key
  bucket.object(path)
end