Class: FilesController

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

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create
  options = {
    :key  => params[:id],
    :body => File.open(File.expand_path "nouns.txt")
  }
  container.create options
end

#destroyObject



20
21
22
# File 'app/controllers/files_controller.rb', line 20

def destroy
  file.destroy
end

#downloadObject



24
25
26
27
28
29
30
# File 'app/controllers/files_controller.rb', line 24

def download
  File.open((File.expand_path "download-" + params[:id]), 'w') do | f |
    container.get(params[:id]) do | data, remaining, content_length |
      f.syswrite data
    end
  end
end

#indexObject



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

def index
  container.all
end

#showObject



16
17
18
# File 'app/controllers/files_controller.rb', line 16

def show
  file
end