Class: ActivestorageDatabase::FilesController

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

Instance Method Summary collapse

Instance Method Details

#showObject



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

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



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

def update
  if (token = decode_verified_token)
    if acceptable_content?(token)
      database_service.upload(token[:key], request.body, checksum: token[:checksum])
    else
      head :unprocessable_entity
    end
  else
    head :not_found
  end
rescue ActiveStorage::IntegrityError
  head :unprocessable_entity
end