Add file download function

This commit is contained in:
kyg516
2016-09-19 19:57:10 +09:00
parent bffd4d7cad
commit ab00afa513
4 changed files with 428 additions and 380 deletions

View File

@@ -5,8 +5,18 @@ class HomeController < ApplicationController
@current_dir = "/mnt"
file_directory(@current_dir)
end
def file_download
@file_name = params[:file_name]
puts "file_name: " + @file_name
if File.exist?(@file_name)
#File.delete(@file_name)
puts "file exist!!"
send_file(@file_name)
puts "send success"
end
end
def make_directory
current_dir = params[:current_dir]
directory_name = params[:directory_name]
@@ -14,8 +24,7 @@ class HomeController < ApplicationController
`sudo mkdir #{current_dir}/#{directory_name}`
redirect_to '/home/index'
end
def delete_file
file_name = params[:file_name]
puts "rm #{file_name} -rf"