Class: SvgExport::SvgController

Inherits:
ApplicationController show all
Defined in:
app/controllers/svg_export/svg_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/svg_export/svg_controller.rb', line 5

def create
  if Engine.batik_path.blank?
    raise ArgumentError.new("Set SvgExport::Engine.batik_path = '...' to the correct path of the batik-rasterizer")
  end
  wrapper = CommandWrapper.new(params, base_url: request.referer)
  begin
    file = wrapper.()
  rescue SvgExport::Error => e
    render :text => "Unable to export image;\n #{e}", status: 422
    return
  end
  send_file file, type: wrapper.type, filename: wrapper.filename, disposition: 'attachment', stream: false
end