Class: Imgproxy::UrlAdapters::ActiveStorageS3

Inherits:
ActiveStorage show all
Defined in:
lib/imgproxy/url_adapters/active_storage_s3.rb

Overview

Adapter for ActiveStorage with S3 service

Imgproxy.configure do |config|
  config.url_adapters.add Imgproxy::UrlAdapters::ActiveStorageS3.new
end

Imgproxy.url_for(user.avatar)

Instance Method Summary collapse

Instance Method Details

#applicable?(image) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
16
# File 'lib/imgproxy/url_adapters/active_storage_s3.rb', line 13

def applicable?(image)
  super &&
    image.service.is_a?(::ActiveStorage::Service::S3Service)
end

#url(image) ⇒ Object



18
19
20
# File 'lib/imgproxy/url_adapters/active_storage_s3.rb', line 18

def url(image)
  "s3://#{image.service.bucket.name}/#{image.key}"
end