Class: SmartEditor::EditorImagesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- SmartEditor::EditorImagesController
- Defined in:
- app/controllers/smart_editor/editor_images_controller.rb
Instance Method Summary collapse
Instance Method Details
#create_for_html5 ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/controllers/smart_editor/editor_images_controller.rb', line 9 def create_for_html5 tempfile_path = Rails.root.join('public', 'uploads', request.headers["file-name"]) File.open(tempfile_path, 'wb+') do |file| file.write(request.body.read) end uploaded_file = ActionDispatch::Http::UploadedFile.new :filename => request.headers["file-name"], :type => request.headers["file-type"], :tempfile => File.open(tempfile_path, 'r') @editor_image = SmartEditor::EditorImage.new(:file => uploaded_file) if @editor_image.save @result = true File.delete(tempfile_path) render :text => "iImageID=#{@editor_image.id}&sFileURL=#{@editor_image.file.url}&bNewLine=true" else @result = false render :text => "image upload failed" end end |
#create_without_html5 ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/controllers/smart_editor/editor_images_controller.rb', line 28 def create_without_html5 @editor_image = SmartEditor::EditorImage.new(params[:editor_image]) if @editor_image.save @result = true url = "#{params[:callback]}?callback_func=#{params[:callback_func]}&iImageID=#{@editor_image.id}&sFileURL=#{@editor_image.file.url}&bNewLine=true" redirect_to url else @result = false end end |
#index ⇒ Object
6 7 |
# File 'app/controllers/smart_editor/editor_images_controller.rb', line 6 def index end |