Class: Shimmer::FilesController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
lib/shimmer/controllers/files_controller.rb

Instance Method Summary collapse

Instance Method Details

#showObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/shimmer/controllers/files_controller.rb', line 5

def show
  expires_in 1.year, public: true
  request.session_options[:skip] = true # prevents a session cookie from being set (would prevent caching on CDNs)

  proxy = FileProxy.restore(params.require(:id))
  send_data(
    proxy.file,
    filename: proxy.filename.to_s,
    type: proxy.content_type,
    disposition: "inline"
  )
rescue ActiveRecord::RecordNotFound, ActiveStorage::FileNotFoundError
  head :not_found
end