Class: SimpleDragonflyPreview::ImageController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/simple_dragonfly_preview/image_controller.rb

Instance Method Summary collapse

Instance Method Details

#iframeObject



22
23
# File 'app/controllers/simple_dragonfly_preview/image_controller.rb', line 22

def iframe
end

#uploadObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/simple_dragonfly_preview/image_controller.rb', line 4

def upload
  if params[:image].present?
    app = Dragonfly.app
    uid = app.store(params[:image].tempfile)
    
    @image = app.fetch(uid)
    attributes_hash = {
      uid: uid
    }
    if params[:attribute_keys].split(",").include?("name")
      attributes_hash.merge! name: params[:image].original_filename
    end
    @retained_image = Dragonfly::Serializer.json_b64_encode(attributes_hash) if @image 
    @resize = params[:resize]
  end
  render :iframe
end