Class: ActiveStorage::DiskController
- Inherits:
-
BaseController
- Object
- AbstractController::Base
- ActionController::Metal
- ActionController::Base
- BaseController
- ActiveStorage::DiskController
- Includes:
- FileServer
- Defined in:
- activestorage/app/controllers/active_storage/disk_controller.rb
Overview
Serves files stored with the disk service in the same way that the cloud services do. This means using expiring, signed URLs that are meant for immediate access, not permanent linking. Always go through the BlobsController, or your own authenticated controller, rather than directly to the service URL.
Constant Summary
Constants inherited from ActionController::Base
ActionController::Base::MODULES, ActionController::Base::PROTECTED_IVARS
Constants included from ActionController::ParamsWrapper
ActionController::ParamsWrapper::EXCLUDE_PARAMETERS
Constants included from ActiveSupport::Callbacks
ActiveSupport::Callbacks::CALLBACK_FILTER_TYPES
Constants included from ActionController::DataStreaming
ActionController::DataStreaming::DEFAULT_SEND_FILE_DISPOSITION, ActionController::DataStreaming::DEFAULT_SEND_FILE_TYPE
Constants included from ActionController::Rendering
ActionController::Rendering::RENDER_FORMATS_IN_PRIORITY
Constants included from ActionController::RequestForgeryProtection
ActionController::RequestForgeryProtection::CSRF_TOKEN
Constants included from ActionController::Renderers
ActionController::Renderers::RENDERERS
Constants included from ActionController::Redirecting
ActionController::Redirecting::ILLEGAL_HEADER_VALUE_REGEX
Constants included from AbstractController::Rendering
AbstractController::Rendering::DEFAULT_PROTECTED_INSTANCE_VARIABLES
Instance Method Summary collapse
Methods included from ActiveSupport::Concern
#append_features, #class_methods, extended, #included, #prepend_features, #prepended
Methods inherited from ActionController::Base
Methods included from ActionController::Instrumentation
#initialize, #redirect_to, #render, #send_data, #send_file
Methods included from ActionController::Rescue
Methods included from ActiveSupport::Rescuable
#handler_for_rescue, #rescue_with_handler
Methods included from ActiveSupport::Callbacks
Methods included from ActionController::HttpAuthentication::Token::ControllerMethods
#authenticate_or_request_with_http_token, #authenticate_with_http_token, #request_http_token_authentication
Methods included from ActionController::HttpAuthentication::Digest::ControllerMethods
#authenticate_or_request_with_http_digest, #authenticate_with_http_digest, #request_http_digest_authentication
Methods included from ActionController::HttpAuthentication::Basic::ControllerMethods
#authenticate_or_request_with_http_basic, #authenticate_with_http_basic, #http_basic_authenticate_or_request_with, #request_http_basic_authentication
Methods included from ActionController::Rendering
#render, #render_to_body, #render_to_string
Methods included from AbstractController::Helpers
Methods included from AbstractController::Helpers::Resolution
#all_helpers_from_path, #helper_modules_from_paths, #modules_for_helpers
Methods included from ActionController::RequestForgeryProtection
#commit_csrf_token, #initialize, #reset_csrf_token
Methods included from ActionController::FormBuilder
Methods included from ActionController::StrongParameters
Methods included from ActionController::ImplicitRender
#default_render, #method_for_action
Methods included from ActionController::BasicImplicitRender
Methods included from ActionController::MimeResponds
Methods included from ActionController::ConditionalGet
#expires_in, #expires_now, #fresh_when, #http_cache_forever, #no_store, #stale?
Methods included from ActionController::Head
Methods included from ActionController::Renderers
#_render_to_body_with_renderer, _render_with_renderer_method_name, add, remove, #render_to_body
Methods included from ActionView::Layouts
#_process_render_template_options, #action_has_layout?, #initialize
Methods included from ActionView::Rendering
#initialize, #process, #render_to_body, #view_context, #view_context_class, #view_renderer
Methods included from ActionView::ViewPaths
#_prefixes, #append_view_path, #details_for_lookup, #lookup_context, #prepend_view_path
Methods included from ActionController::Redirecting
_compute_redirect_to_location, #_compute_redirect_to_location, #redirect_back, #redirect_back_or_to, #redirect_to, #url_from
Methods included from ActionController::UrlFor
Methods included from AbstractController::UrlFor
Methods included from ActionDispatch::Routing::UrlFor
#full_url_for, #initialize, #route_for, #url_for, #url_options
Methods included from ActionDispatch::Routing::PolymorphicRoutes
#polymorphic_path, #polymorphic_url
Methods included from ActionController::Helpers
Methods included from AbstractController::Translation
Methods included from AbstractController::Rendering
#render, #render_to_body, #render_to_string, #rendered_format, #view_assigns
Methods inherited from ActionController::Metal
action, action_encoding_template, #content_type, #content_type=, #controller_name, controller_name, dispatch, #dispatch, #headers, #initialize, #location, #location=, make_response!, #media_type, middleware, #params, #params=, #performed?, #request, #reset_session, #response, #response=, #response_body=, #session, #set_request!, #set_response!, #status, #status=, #to_a, #url_for, use
Methods included from ActionController::Testing::Functional
#clear_instance_variables_between_requests, #recycle!
Methods inherited from AbstractController::Base
abstract!, action_methods, #action_methods, #action_name, #available_action?, clear_action_methods!, controller_path, #controller_path, eager_load!, #formats, inherited, #inspect, internal_methods, method_added, #performed?, #process, #response_body, supports_path?
Methods included from ActiveSupport::DescendantsTracker
clear, #descendants, descendants, disable_clear!, reject!, subclasses
Methods included from ActiveSupport::Configurable
Instance Method Details
#show ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'activestorage/app/controllers/active_storage/disk_controller.rb', line 12 def show if key = decode_verified_key serve_file named_disk_service(key[:service_name]).path_for(key[:key]), content_type: key[:content_type], disposition: key[:disposition] else head :not_found end rescue Errno::ENOENT head :not_found end |
#update ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'activestorage/app/controllers/active_storage/disk_controller.rb', line 22 def update if token = decode_verified_token if acceptable_content?(token) named_disk_service(token[:service_name]).upload token[:key], request.body, checksum: token[:checksum] head :no_content else head :unprocessable_entity end else head :not_found end rescue ActiveStorage::IntegrityError head :unprocessable_entity end |