Class: AmcmsFilemanager::FilemanagerController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- AmcmsFilemanager::FilemanagerController
- Defined in:
- app/controllers/amcms_filemanager/filemanager_controller.rb
Instance Method Summary collapse
- #change_directory ⇒ Object
- #copy ⇒ Object
- #destroy ⇒ Object
- #index ⇒ Object
- #mkdir ⇒ Object
- #rename ⇒ Object
- #upload ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#change_directory ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/amcms_filemanager/filemanager_controller.rb', line 21 def change_directory @files = AmcmsFilemanager::Filemanager.list(params[:cd], params[:type]) render json: { files: @files, pwd: pwd, pwd_name: pwd.split('/').last, root_directory: AmcmsFilemanager.config.root_path, parent_directory: AmcmsFilemanager::Filemanager.parent_dir(params[:cd]) } end |
#copy ⇒ Object
33 34 35 36 37 38 39 |
# File 'app/controllers/amcms_filemanager/filemanager_controller.rb', line 33 def copy if AmcmsFilemanager::Filemanager.copy(params[:item_name]) render json: { success: true }, status: 200 else render json: { success: false }, status: 400 end end |
#destroy ⇒ Object
57 58 59 60 61 62 63 |
# File 'app/controllers/amcms_filemanager/filemanager_controller.rb', line 57 def destroy if AmcmsFilemanager::Filemanager.delete(params[:file]) render json: { success: true }, status: 200 else render json: { success: false }, status: 400 end end |
#index ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/controllers/amcms_filemanager/filemanager_controller.rb', line 7 def index @config = { routes: { cd_path: filemanager_change_directory_path, mkdir_path: filemanager_mkdir_path, rm_path: filemanager_destroy_path, rename_path: filemanager_rename_path, copy_path: filemanager_copy_path, image_info_path: imagemanager_path(':id'), }, type: params.fetch(:type, 'all') } end |
#mkdir ⇒ Object
41 42 43 44 45 46 47 |
# File 'app/controllers/amcms_filemanager/filemanager_controller.rb', line 41 def mkdir if AmcmsFilemanager::Filemanager.mkdir(params[:pwd], params[:item_name]) render json: { success: true }, status: 200 else render json: { success: false }, status: 400 end end |
#rename ⇒ Object
49 50 51 52 53 54 55 |
# File 'app/controllers/amcms_filemanager/filemanager_controller.rb', line 49 def rename if AmcmsFilemanager::Filemanager.rename(params[:pwd], params[:original_filename], params[:item_name]) render json: { success: true }, status: 200 else render json: { success: false }, status: 400 end end |
#upload ⇒ Object
65 66 67 68 69 70 71 72 73 |
# File 'app/controllers/amcms_filemanager/filemanager_controller.rb', line 65 def upload if AmcmsFilemanager::Filemanager::upload(params[:dir], params[:file], params[:type]) render json: { success: true }, status: 200 else render json: { success: false }, status: 400 end rescue CarrierWave::IntegrityError => e render json: { error: e. }, status: 400 end |