Getting a Binary Reponse using Curb

Hi guys,

I am new to ruby. I have the following problem.

I have a rendering engine that will take a svg and a set of params and
return a PNG image.

If I use curl on the command line passing the SVG it returns the image
as PNG and everything looks good.

I am trying to issue the same command using CURB but I have no idea how
to get the binary body.

I tried the following code:

  def get_product_image_curl(svg, image_name, w, h, region,

alignment)
preview_url =
“http://#{APP_CONFIG[‘preview_server’]}/merchandise/#{image_name}?region=name:#{region},w:#{w},h:#{h},a:#{alignment}”

  c = Curl::Easy.new(preview_url)
  svg = URI.escape(svg,

Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
c.http_post(Curl::PostField.content(‘design’, svg,
‘application/x-www-form-urlencoded’))

  return c.body_str
end

The body returns empty

The curls that works (same svg)
curl -v --data-urlencode [email protected] “http:///merchandise/344_480x480_Front.png?region=name:FrontCenter,w:23,h:63,a:TopCenter”

prod.png

Any idea how to get the body our of the response?

Thanks in advance
Dalmer Azevedo

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs