module Shrine::Plugins::UploadEndpoint::ClassMethods

  1. lib/shrine/plugins/upload_endpoint.rb

Methods

Public Instance

  1. upload_endpoint

Public Instance methods

upload_endpoint (storage_key, **options)

Returns a Rack application (object that responds to #call) which accepts multipart POST requests to the root URL, uploads given file to the specified storage, and returns that information in JSON format.

The storage_key needs to be one of the registered Shrine storages. Additional options can be given to override the options given on plugin initialization.

[show source]
# File lib/shrine/plugins/upload_endpoint.rb, line 126
def upload_endpoint(storage_key, **options)
  App.new({
    shrine_class:   self,
    storage_key:    storage_key,
    max_size:       opts[:upload_endpoint_max_size],
    upload_context: opts[:upload_endpoint_upload_context],
    upload:         opts[:upload_endpoint_upload],
    rack_response:  opts[:upload_endpoint_rack_response],
  }.merge(options))
end