Class: Activestorage::Memory::MemoryController

Inherits:
ActiveStorage::BaseController
  • Object
show all
Defined in:
app/controllers/activestorage/memory/memory_controller.rb

Instance Method Summary collapse

Instance Method Details

#showObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/activestorage/memory/memory_controller.rb', line 7

def show
  key = decode_verified_key

  unless key
    head :not_found
    return
  end

  service = named_memory_service(key[:service_name])
  if service.exist?(key[:key])
    send_data(service.store[key[:key]], content_type: key[:content_type], disposition: key[:disposition])
  else
    head :not_found
  end
end

#updateObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/activestorage/memory/memory_controller.rb', line 23

def update
  token = decode_verified_token

  unless token
    head :not_found
    return
  end

  unless acceptable_content?(token)
    head :unprocessable_entity
    return
  end

  named_memory_service(token[:service_name]).upload token[:key], request.body, checksum: token[:checksum]
  head :no_content
end