<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: how can i read File from Database</title><link>https://answers.axonivy.com/questions/2675/how-can-i-read-file-from-database</link><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I have a BLOB file in my mysql database. 
When reading, the line is a recor&lt;img alt="alt text" src="http://answers.axonivy.com/upfiles/Bildschirmfoto_2017-06-06_um_15.39.10_K1murx1.png"&gt;d and the field (blob) is an Object. 
How do I convert an object to a file data type from the ivyscript?&lt;/p&gt;
&lt;p&gt;You can see it at the attachmend.&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/2675/how-can-i-read-file-from-database" rel="self"></atom:link><language>en</language><lastBuildDate>Thu, 08 Jun 2017 11:36:52 -0400</lastBuildDate><item><title>Answer by Reto Weiss</title><link>https://answers.axonivy.com/questions/2675/how-can-i-read-file-from-database/2687</link><description>&lt;p&gt;Hi &lt;/p&gt;
&lt;p&gt;You can do it like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Binary binary = in.Data.document.document.getField("File") as Binary;
File file = new File(in.Data.document.document.getField("Name").toString());
file.writeBinary(binary);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You first have to cast the Object returned from getField to a Binary using the &lt;code&gt;as&lt;/code&gt; operator of IvyScript&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Reto Weiss, Axon.ivy Support&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Reto Weiss</dc:creator><pubDate>Thu, 08 Jun 2017 11:36:52 -0400</pubDate><guid>https://answers.axonivy.com/questions/2675/how-can-i-read-file-from-database/2687</guid></item></channel></rss>