Class: EziiOsFilesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- EziiOsFilesController
- Defined in:
- app/controllers/ezii_os_files_controller.rb
Overview
typed: false
Instance Method Summary collapse
-
#create ⇒ Object
POST /ezii_os_files POST /ezii_os_files.json.
-
#destroy ⇒ Object
DELETE /ezii_os_files/1 DELETE /ezii_os_files/1.json.
-
#edit ⇒ Object
GET /ezii_os_files/1/edit.
-
#index ⇒ Object
GET /ezii_os_files GET /ezii_os_files.json.
-
#new ⇒ Object
GET /ezii_os_files/new.
-
#show ⇒ Object
GET /ezii_os_files/1 GET /ezii_os_files/1.json.
-
#update ⇒ Object
PATCH/PUT /ezii_os_files/1 PATCH/PUT /ezii_os_files/1.json.
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
POST /ezii_os_files POST /ezii_os_files.json
104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'app/controllers/ezii_os_files_controller.rb', line 104 def create @ezii_os_file = EziiOsFile.new(ezii_os_file_params) respond_to do |format| if @ezii_os_file.save format.html { redirect_to @ezii_os_file, notice: 'Ezii os file was successfully created.' } format.json { render :show, status: :created, location: @ezii_os_file } else format.html { render :new } format.json { render json: @ezii_os_file.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /ezii_os_files/1 DELETE /ezii_os_files/1.json
134 135 136 137 138 139 140 |
# File 'app/controllers/ezii_os_files_controller.rb', line 134 def destroy @ezii_os_file.destroy respond_to do |format| format.html { redirect_to ezii_os_files_url, notice: 'Ezii os file was successfully destroyed.' } format.json { head :no_content } end end |
#edit ⇒ Object
GET /ezii_os_files/1/edit
99 100 |
# File 'app/controllers/ezii_os_files_controller.rb', line 99 def edit end |
#index ⇒ Object
GET /ezii_os_files GET /ezii_os_files.json
17 18 19 |
# File 'app/controllers/ezii_os_files_controller.rb', line 17 def index @ezii_os_files = EziiOsFile.all end |
#new ⇒ Object
GET /ezii_os_files/new
94 95 96 |
# File 'app/controllers/ezii_os_files_controller.rb', line 94 def new @ezii_os_file = EziiOsFile.new end |
#show ⇒ Object
GET /ezii_os_files/1 GET /ezii_os_files/1.json
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'app/controllers/ezii_os_files_controller.rb', line 23 def show @path = EziiOsPath.new(params[:id]) case @path.file_system.machine_readable_identifier when 'local' @last_file_input = File.read(@path.file_system_path) if params[:id].match(/\/public\/(.*)\Z/) relative_path_to_file = params[:id].match(/\/public\/(.*)\Z/)[1] @path.https_url = '/' + relative_path_to_file.gsub(/\s/, '%20') else # @path.file_system_path = params[:id].gsub(/\A\/?local/, '') # @path.local_file_system_path = params[:id].gsub(/\A\/?local/, '') end when 'dropbox' bda = BanalDropboxApi.new §( ASSERT_NO_DROPBOX_API_ERRORS, TEMPFILES_MUST_BE_SUPPORTED, CHECK_FOR_TEMPFILE_NOT_REWINDED_ISSUE ) do bda.download(@path.file_system_path) do |file_content| @last_file_input = file_content t = Tempfile.new(['file', File.extname(@path.file_system_path)]) t.binmode t.write(file_content) @path.local_file_system_path = t.path end end if File.extname(@path.file_system_path) == '.shp' remote_path = @path.file_system_path local_path = @path.local_file_system_path %w(.shx .dbf).each do |file_extension| §( ASSERT_NO_DROPBOX_API_ERRORS, TEMPFILES_MUST_BE_SUPPORTED, CHECK_FOR_TEMPFILE_NOT_REWINDED_ISSUE ) do bda.download(remote_path.gsub('.shp', file_extension)) do |file_content| t = Tempfile.new(['file', file_extension]) t.binmode #TODO: figure out why this had to be attempted multiple times for the write to work t.write(file_content) #END-TODO t.rewind `ln -s #{t.path} #{local_path.gsub('.shp', file_extension)}` @path.complementary_local_file_system_paths.push(local_path.gsub('.shp', file_extension)) end end end end @path.https_url = bda.get_link(@path.file_system_path) rescue nil end end |
#update ⇒ Object
PATCH/PUT /ezii_os_files/1 PATCH/PUT /ezii_os_files/1.json
120 121 122 123 124 125 126 127 128 129 130 |
# File 'app/controllers/ezii_os_files_controller.rb', line 120 def update respond_to do |format| if @ezii_os_file.update(ezii_os_file_params) format.html { redirect_to @ezii_os_file, notice: 'Ezii os file was successfully updated.' } format.json { render :show, status: :ok, location: @ezii_os_file } else format.html { render :edit } format.json { render json: @ezii_os_file.errors, status: :unprocessable_entity } end end end |