Class: FileExplorer::IndexController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- FileExplorer::IndexController
- Includes:
- ActionView::Helpers::NumberHelper
- Defined in:
- app/controllers/file_explorer/index_controller.rb
Constant Summary collapse
- BASE_DIRECTORY =
ENV['BASE_DIRECTORY'] || '.'
Instance Method Summary collapse
Instance Method Details
#delete ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/file_explorer/index_controller.rb', line 32 def delete absolute_path = check_path(params[:path]) if File.directory?(absolute_path) FileUtils.rm_rf(absolute_path) else FileUtils.rm(absolute_path) end redirect_to request.referrer, notice: "DELETED!! DELETED!!!" head 204 end |
#folder_create ⇒ Object
43 44 45 46 |
# File 'app/controllers/file_explorer/index_controller.rb', line 43 def folder_create `mkdir #{params[:index].fetch(:name)}` redirect_to request.referrer, notice: "#{params[:index].fetch(:name)} FOLDER CREATED!" end |
#index ⇒ Object
9 10 11 12 |
# File 'app/controllers/file_explorer/index_controller.rb', line 9 def index populate_directory(BASE_DIRECTORY, '') @absolute_path = BASE_DIRECTORY end |
#path ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/file_explorer/index_controller.rb', line 14 def path absolute_path = check_path(params[:path]) if File.directory?(absolute_path) populate_directory(absolute_path, "#{params[:path]}/") render :index elsif File.file?(absolute_path) if File.size(absolute_path) > 2500_000 #send_file absolute_path redirect_to request.referrer, notice: "Not Loadable. . . Way to big!" else @file = File.read(absolute_path) render :file, formats: :html end end end |