โ€”

title: Shrine 2.7.0

New Plugins

Shrine.plugin :upload_endpoint

# config.ru
map "/images/upload" do
  run ImageUploader.upload_endpoint(:cache)
end # creates a `POST /images/upload` endpoint
Shrine.plugin :presign_endpoint

# config.ru
map "/presign" do
  run Shrine.presign_endpoint(:cache)
end # creates a `GET /presign` endpoint
Shrine.plugin :rack_response
class FilesController < ActionController::Base
  def download
    # ...
    file_response = record.attachment.to_rack_response # returns a Rack response triple

    response.status = file_response[0]
    response.headers.merge!(file_response[1])
    self.response_body = file_response[2]
  end
end

New Features

Shrine.plugin :determine_mime_type, analyzer: :mini_mime
class Photo
  include ImageUploader::Attachment.new(:image, cache: :other_cache, store: :other_store)
end
validate_max_size 256 * 1024**2, message: -> (max) { [:too_large, max: max] }

Other Improvements

gem "aws-sdk-s3", "~> 1.2"
class ImageUploader < Shrine
  Attacher.validate do
    # ...
  end
end
class ProfileImageUploader < ImageUploader
  Attacher.validate do
    super() # empty parentheses are required
    # ...
  end
end

Backwards compatibility

map "/attachments" do
  use MyMiddleware
  run Shrine.download_endpoint
end