Hello, I have a BLOB file in my mysql database. When reading, the line is a record and the field (blob) is an Object. How do I convert an object to a file data type from the ivyscript? You can see it at the attachmend. Thanks asked 06.06.2017 at 09:44 metehan |
Hi You can do it like this:
You first have to cast the Object returned from getField to a Binary using the Regards Reto Weiss, Axon.ivy Support answered 08.06.2017 at 11:36 Reto Weiss ♦♦ Hi, thank you very much for your great support. Cast a objekt to binary is working now. But if I download the file (tried with text and PDF files) by using DefaultStreamedContent, I am not able to open it, because there are some special characters: ¨Ìsr'ch.ivyteam.ivy.scripting.objects.Binary[bytest[Bxpur[B¨Û¯T‡xpTestHalloTest It seems that the encoding is wrong. Best Regards, Eugene
(08.06.2017 at 12:59)
Eugene
Hi Eugene This seems to be more a support topic than a simple Q&A now. Can we continue this on our Support channel? To do so please send a mail to ivy@axonivy.com. Regards Reto Weiss, Axon.ivy Support
(09.06.2017 at 05:16)
Reto Weiss ♦♦
|
Once you sign in you will be able to subscribe for any updates here
By RSS:Markdown Basics
Tags:
Asked: 06.06.2017 at 09:44
Seen: 2,082 times
Last updated: 09.06.2017 at 05:16
Do your read the Record with the Database Step process element?
Yes the Record is the parameter. I would like to convert the object from the record into a file Type.
Object can be anything. What is the type of the Object returned by getField() at runtime? You can log that by the following code: ivy.log.info(in.Data.document.document.getField("File").getClass().toString()) If we know the type that is returned there we can find a solution to store the data to a file.
We save the file over the database process element as a blob with in.file.readBinary() Runtime log by using in.Data.document.document.getField("File").getClass().toString() give us: class ch.ivyteam.ivy.scripting.objects.Binary I tried this: File file = new File(in.data.document.document.getField("Name").toString()); file.writeBinary(in.Data.document.document.getField("File")); But I get the following error: Method writeBinary(Object) for class file of classloader org.eclipse.osgi.internal.loader.EquinoxClassLoader@44c54463[ch.ivyteam.ivy.scripting.objects:6.6.1.201705151238(id=84)] not found.