Hi all,
Im reading XML file which has Content tag which has binary data(i
assume). I need to read that content and store it as image.
Content Data in XML looks like this:
WEcxA1HTcsbiHgufPW41U1Du0HAdIY/WvTSB1s9NGtgW4W4BMSHJnnjF/m4K+vKuF0d8Q29yLWNzlvmT9orboet9EYouFMX9QvG3sV0PO7/gtXF7BjQGhGoSzh+Pg8iWk705TkOSm/5LrKOsqx5JrCNh4eqHTyuWBhV6PGDV+AUack69Diqei+DJUn2ze+5otVoSs2mgpiV4Wmp9Djc0rYXrrqDpmcxjIfo61uK3JpvaFBConokCgR1JKNS6BgMIDg==
XML Tag is :
WEcxA1HTcsbiHgufPW41U1Du0HAdIY/WvTSB1s9NGtgW4W4BMSHJnnjF/m4K+vKuF0d8Q29yLWNzlvmT9orboet9EYouFMX9QvG3sV0PO7/gtXF7BjQGhGoSzh+Pg8iWk705TkOSm/5LrKOsqx5JrCNh4eqHTyuWBhV6PGDV+AUack69Diqei+DJUn2ze+5otVoSs2mgpiV4Wmp9Djc0rYXrrqDpmcxjIfo61uK3JpvaFBConokCgR1JKNS6BgMIDg==
Please find the attach sample xml data. Code written so far is as
follows,
require ‘base64’
@content =
‘WEcxAyEJQTXiHgufhAdVefCCvSH2njBUZ/dzBOsTuNj9guPeaJrJL80KjGWl8dglgJ56veLnyl/Fdu8I1tS7uAR65G82/WxygyR/lOE7bNLMCHS1p3Ah48iCzQBSJ1jnOl1HuL8hAR0aGhHIN8oW7IofdVX0YPSaQoanrUkz7iPt56TbZH5qiynHqLD9ZepkDGpSAUuInzLZG/2BixmyuqH2ctZnMqPAJR4vveB7mT7KVsJRIofMZqK6ptHWRAmk4w==’
@filename= ‘Sana.jpg’
File.open(@filename, ‘wb’) do|f|
f.write(Base64.decode64(@content))
end
Please help im new to Ruby