module Shrine::Plugins::UploadEndpoint::ClassMethods
Public Instance Methods
upload_endpoint(storage_key, **options)
click to toggle source
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.
# File lib/shrine/plugins/upload_endpoint.rb, line 29 def upload_endpoint(storage_key, **options) Shrine::UploadEndpoint.new( shrine_class: self, storage_key: storage_key, **opts[:upload_endpoint], **options, ) end
upload_response(storage_key, env, **options)
click to toggle source
Calls the upload endpoint passing the request information, and returns the Rack response triple.
It performs the same mounting logic that Rack and other web frameworks use, and is meant for cases where statically mounting the endpoint in the router isn’t enough.
# File lib/shrine/plugins/upload_endpoint.rb, line 44 def upload_response(storage_key, env, **options) script_name = env["SCRIPT_NAME"] path_info = env["PATH_INFO"] begin env["SCRIPT_NAME"] += path_info env["PATH_INFO"] = "" upload_endpoint(storage_key, **options).call(env) ensure env["SCRIPT_NAME"] = script_name env["PATH_INFO"] = path_info end end