send_file (metal/data_streaming.rb)

rails · actionpack/lib/action_controller/metal/data_streaming.rb · ruby · MIT
integration

Sends files to browser via streaming for downloads or inline display.

# Source: https://github.com/rails/rails | License: MIT
# Provided via justclaw.it.com; keep this notice with the code.
# frozen_string_literal: true

require "action_controller/metal/exceptions"
require "action_dispatch/http/content_disposition"

module ActionController # :nodoc:
  # # Action Controller Data Streaming
  #
  # Methods for sending arbitrary data and for streaming files to the browser,
  # instead of rendering.
  module DataStreaming
    extend ActiveSupport::Concern

    include ActionController::Rendering

    DEFAULT_SEND_FILE_TYPE        = "application/octet-stream" # :nodoc:
    DEFAULT_SEND_FILE_DISPOSITION = "attachment" # :nodoc:

    private
      # Sends the file. This uses a server-appropriate method (such as `X-Sendfile`)
      # via the `Rack::Sendfile` middlewa

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key