Class: Dscf::Core::FilesController

Inherits:
ApplicationController show all
Includes:
FileUploadable
Defined in:
app/controllers/dscf/core/files_controller.rb

Overview

Controller for serving file attachments from MinIO storage Provides download endpoints for files uploaded via the Attachable concern

Examples:

Download a file

GET /dscf/core/files/:file_key
GET /dscf/core/files/:file_key?download=true  # Force download

Instance Method Summary collapse

Methods included from FileUploadable

#after_save_hook, #attach_files, #auto_attach_files, #file_upload_strict_mode?, #process_base64_file, #send_attachment, #send_stored_file, #upload_base64_file, #upload_file, #upload_files

Methods included from Authorizable

#authorize, #authorize_action!, #policy_scope, #pundit_user

Methods included from JsonResponse

#render_error, #render_success, #serialize

Methods included from TokenAuthenticatable

#require_valid_refresh_token, #validate_device_consistency, #validate_token_expiry

Methods included from Authenticatable

#authenticate_user, #authenticate_user!, #current_user, #refresh_token, #sign_in, #sign_out

Instance Method Details

#showObject

GET /dscf/core/files/:file_key Serves a file from MinIO storage



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/dscf/core/files_controller.rb', line 21

def show
  attachment = FileAttachment.find_by(file_key: params[:file_key])

  unless attachment
    render json: {success: false, error: "File not found"}, status: :not_found
    return
  end

  disposition = params[:download].present? ? "attachment" : "inline"

  send_attachment(
    attachment,
    disposition: disposition
  )
end