module Shrine::Plugins::PresignEndpoint::ClassMethods
Public Instance Methods
# File lib/shrine/plugins/presign_endpoint.rb 24 def presign_endpoint(storage_key, **) 25 Shrine::PresignEndpoint.new( 26 shrine_class: self, 27 storage_key: storage_key, 28 **opts[:presign_endpoint], 29 **, 30 ) 31 end
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 39 def presign_response(storage_key, env, **) 40 script_name = env["SCRIPT_NAME"] 41 path_info = env["PATH_INFO"] 42 43 begin 44 env["SCRIPT_NAME"] += path_info 45 env["PATH_INFO"] = "" 46 47 presign_endpoint(storage_key, **).call(env) 48 ensure 49 env["SCRIPT_NAME"] = script_name 50 env["PATH_INFO"] = path_info 51 end 52 end
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.