class Shrine::Plugins::UploadEndpoint::App

  1. lib/shrine/plugins/upload_endpoint.rb
Superclass: Object

Rack application that accepts multipart POST request to the root URL, calls #upload with the uploaded file, and returns the uploaded file information in JSON format.


Public Class

  1. new

Public Instance

  1. call

Public Class methods

new (options)

Writes given options to instance variables.

[show source]
# File lib/shrine/plugins/upload_endpoint.rb, line 153
def initialize(options)
  options.each do |name, value|
    instance_variable_set("@#{name}", value)

Public Instance methods

call (env)

Accepts a Rack env hash, routes POST requests to the root URL, and returns a Rack response triple.

If request isn't to the root URL, a 404 Not Found response is returned. If request verb isn't GET, a 405 Method Not Allowed response is returned.

[show source]
# File lib/shrine/plugins/upload_endpoint.rb, line 165
def call(env)
  request =

  status, headers, body = catch(:halt) do
    error!(404, "Not Found") unless ["", "/"].include?(request.path_info)
    error!(405, "Method Not Allowed") unless


  headers["Content-Length"] =, :+).to_s

  [status, headers, body]