On Thu, Dec 29, 2011 at 8:41 AM, Sagar Varule <sagar.varule / gmail.com> wrot=
e:
> 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.
>
> Data in XML looks like this:
> WEcxA1HTcsbiHgufPW41U1Du0HAdIY/WvTSB1s9NGtgW4W4BMSHJnnjF/m4K+vKuF0d8Q29yL=
WNzlvmT9orboet9EYouFMX9QvG3sV0PO7/gtXF7BjQGhGoSzh+Pg8iWk705TkOSm/5LrKOsqx5J=
rCNh4eqHTyuWBhV6PGDV+AUack69Diqei+DJUn2ze+5otVoSs2mgpiV4Wmp9Djc0rYXrrqDpmcx=
jIfo61uK3JpvaFBConokCgR1JKNS6BgMIDg=3D=3D
>
> XML Tag is :
> <CONTENT SRC=3D"gn-content"
> TYPE=3D"cover">WEcxA1HTcsbiHgufPW41U1Du0HAdIY/WvTSB1s9NGtgW4W4BMSHJnnjF/m=
4K+vKuF0d8Q29yLWNzlvmT9orboet9EYouFMX9QvG3sV0PO7/gtXF7BjQGhGoSzh+Pg8iWk705T=
kOSm/5LrKOsqx5JrCNh4eqHTyuWBhV6PGDV+AUack69Diqei+DJUn2ze+5otVoSs2mgpiV4Wmp9=
Djc0rYXrrqDpmcxjIfo61uK3JpvaFBConokCgR1JKNS6BgMIDg=3D=3D</CONTENT>
>
> Please find the attach sample xml data. Code written so far is as
> follows:
>
> require 'base64'
> @content =3D
> 'WEcxAyEJQTXiHgufhAdVefCCvSH2njBUZ/dzBOsTuNj9guPeaJrJL80KjGWl8dglgJ56veLn=
yl/Fdu8I1tS7uAR65G82/WxygyR/lOE7bNLMCHS1p3Ah48iCzQBSJ1jnOl1HuL8hAR0aGhHIN8o=
W7IofdVX0YPSaQoanrUkz7iPt56TbZH5qiynHqLD9ZepkDGpSAUuInzLZG/2BixmyuqH2ctZnMq=
PAJR4vveB7mT7KVsJRIofMZqK6ptHWRAmk4w=3D=3D'
> @filename=3D 'Sana.jpg'
> str =3D Base64.decode64(@content)
> File.open(@filename, 'wb') do|f|
> =A0BinaryString.
> =A0f.write(Base64.decode64(@content))

Why do you decode twice?  You have the binary data already in str.

> end
>
> Please help im new to Ruby
>
> Attachments:
> http://www.ruby-forum.com/attachment/6868/_album__album_cover_search73.lo=
g

And where exactly is the problem?

Kind regards

robert

--=20
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/