Class: ActiveStorageDB::FilesController

Inherits:
ActiveStorage::BaseController
  • Object
show all
Defined in:
app/controllers/active_storage_db/files_controller.rb

Instance Method Summary collapse

Instance Method Details

#showObject



7
8
9
10
11
12
13
14
15
# File 'app/controllers/active_storage_db/files_controller.rb', line 7

def show
  if (key = decode_verified_key)
    serve_file(key[:key], content_type: key[:content_type], disposition: key[:disposition])
  else
    head(:not_found)
  end
rescue ActiveStorage::FileNotFoundError
  head(:not_found)
end

#updateObject



17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/active_storage_db/files_controller.rb', line 17

def update
  if (token = decode_verified_token)
    file_uploaded = upload_file(token, body: request.body)
    head(file_uploaded ? :no_content : :unprocessable_entity)
  else
    head(:not_found)
  end
rescue ActiveStorage::IntegrityError
  head(:unprocessable_entity)
end