add directory

This commit is contained in:
bee0005
2016-08-25 10:22:48 +00:00
parent cbfa6976c7
commit 883f6fcd39
4 changed files with 137 additions and 8 deletions

View File

@@ -1,9 +1,11 @@
class VolumeController < ApplicationController
def info
file_directory('/home/ubuntu')
@volumes = Array.new
volume = Hash.new
i = 0
if get_info.blank?
flash[:danger] = "Check Server"
else
@@ -33,4 +35,29 @@ class VolumeController < ApplicationController
uploader.store!(file_name)
redirect_to '/volume/info'
end
def file_directory(dir)
@current_dir = dir
dir_list = `ls #{@current_dir} -l`
parsing_list = dir_list.split("\n")
@files = Array.new
file = Hash.new
i = 0
@total_list = parsing_list[0]
for t in 1..(parsing_list.length-1)
puts "@@@@@@@@@@@" + parsing_list[t]
parsing_file = parsing_list[t].split(" ")
file["auth"] = parsing_file[0]
file["size"] = parsing_file[4]
file["date"] = parsing_file[5] + " " + parsing_file[6] + " "+ parsing_file[7]
file["name"] = parsing_file[8]
@files[i] = file
file = Hash.new
i+=1
end
puts @files
end
end