Add download function at home controller

This commit is contained in:
kyg516
2016-09-20 18:13:39 +09:00
parent ab00afa513
commit 92a0d71bda
3 changed files with 10 additions and 50 deletions

View File

@@ -1,19 +1,16 @@
class HomeController < ApplicationController
def index
config = get_conf
#@current_dir = config["project_path"]
@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"
@file_name = params[:file_name].gsub(" ", "/")
if !@file_name.nil?
send_file @file_name
else
puts "file name is nil"
redirect_to '/home/index'
end
end