Class: Imgproxy::UrlAdapters::ShrineS3

Inherits:
Shrine
  • Object
show all
Defined in:
lib/imgproxy/url_adapters/shrine_s3.rb

Overview

Adapter for Shrine with S3 storage

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

Imgproxy.url_for(user.avatar)

Instance Method Summary collapse

Methods inherited from Shrine

#initialize

Constructor Details

This class inherits a constructor from Imgproxy::UrlAdapters::Shrine

Instance Method Details

#applicable?(image) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/imgproxy/url_adapters/shrine_s3.rb', line 11

def applicable?(image)
  super && image.storage.is_a?(::Shrine::Storage::S3)
end

#url(image) ⇒ Object



15
16
17
# File 'lib/imgproxy/url_adapters/shrine_s3.rb', line 15

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