Class: FilesController

Inherits:
MVCLI::Controller
  • Object
show all
Defined in:
app/controllers/files_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/files_controller.rb', line 9

def create
  template = Files::CreateForm
  argv = MVCLI::Argv.new command.argv
  form = template.new argv.options
  form.validate!

  options = {
    :key  => params[:id],
    :body => form.file.to_s
  }
  container.create options
end

#destroyObject



26
27
28
# File 'app/controllers/files_controller.rb', line 26

def destroy
  file.destroy
end

#downloadObject



30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/files_controller.rb', line 30

def download
  template = Files::DownloadForm
  argv = MVCLI::Argv.new command.argv
  form = template.new argv.options
  form.validate!

  File.open(form.destination.to_s, 'w') do | f |
    container.get(params[:id]) do | data, remaining, content_length |
      f.syswrite data
    end
  end
end

#indexObject



5
6
7
# File 'app/controllers/files_controller.rb', line 5

def index
  container.all
end

#showObject



22
23
24
# File 'app/controllers/files_controller.rb', line 22

def show
  file
end