module Shrine::Plugins::PresignEndpoint::ClassMethods
Public Instance Methods
presign_endpoint(storage_key, **options)
click to toggle source
Returns a Rack application (object that responds to ‘#call`) which accepts GET requests to the root URL, calls the specified storage to generate the presign, 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/presign_endpoint.rb, line 24 def presign_endpoint(storage_key, **options) Shrine::PresignEndpoint.new( shrine_class: self, storage_key: storage_key, **opts[:presign_endpoint], **options, ) end
presign_response(storage_key, env, **options)
click to toggle source
Calls the presign 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/presign_endpoint.rb, line 39 def presign_response(storage_key, env, **options) script_name = env["SCRIPT_NAME"] path_info = env["PATH_INFO"] begin env["SCRIPT_NAME"] += path_info env["PATH_INFO"] = "" presign_endpoint(storage_key, **options).call(env) ensure env["SCRIPT_NAME"] = script_name env["PATH_INFO"] = path_info end end