2016-08-20 06:41:37 +00:00
|
|
|
class HomeController < ApplicationController
|
2016-09-23 12:53:19 +00:00
|
|
|
before_action :require_login
|
2016-09-24 09:00:27 +00:00
|
|
|
|
2016-09-23 09:28:53 +00:00
|
|
|
def index
|
|
|
|
@current_dir = "/mnt"
|
|
|
|
file_directory(@current_dir)
|
|
|
|
end
|
2016-09-19 10:57:10 +00:00
|
|
|
|
2016-09-23 09:28:53 +00:00
|
|
|
def file_download
|
|
|
|
@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
|
2016-09-19 10:57:10 +00:00
|
|
|
|
2016-09-23 09:28:53 +00:00
|
|
|
def make_directory
|
|
|
|
current_dir = params[:current_dir]
|
|
|
|
directory_name = params[:directory_name]
|
|
|
|
# make directory
|
|
|
|
command = String.new
|
|
|
|
command << "sudo mkdir #{current_dir}/#{directory_name}"
|
|
|
|
puts command
|
|
|
|
`#{command}`
|
|
|
|
redirect_to '/home/index'
|
|
|
|
end
|
2016-09-24 09:00:27 +00:00
|
|
|
|
2016-09-23 09:28:53 +00:00
|
|
|
def delete_file
|
|
|
|
file_name = params[:file_name]
|
|
|
|
# delete file
|
|
|
|
command = String.new
|
|
|
|
command << "sudo rm -rf #{file_name}"
|
|
|
|
puts command
|
2016-09-23 13:45:20 +00:00
|
|
|
`#{command}`
|
2016-09-23 09:28:53 +00:00
|
|
|
redirect_to '/home/index'
|
|
|
|
end
|
2016-09-23 13:45:20 +00:00
|
|
|
|
2016-08-20 06:41:37 +00:00
|
|
|
end
|