<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Add Image to Library via Java-API]]></title><description><![CDATA[<p dir="auto">Hi there,<br />
first of all, thanks for this awesome Software.</p>
<p dir="auto">I am trying to add some Icons to the ImageLibrary via Java-API but i am not sure how to do this.<br />
What I have already tried:</p>
<ul>
<li>Upload png to Server with uuid as Filename, this works, file is in /var/files/</li>
<li>Instantiate new LibraryImage(uuid, Name, category,...), works also, except for empty Image</li>
<li>createImage adds Image to Library with desired Name, but then I get a NullPointerException because of the empty image <img src="https://forum.netxms.org/assets/plugins/nodebb-plugin-emoji/emoji/android/1f615.png?v=72b86a538fc" class="not-responsive emoji emoji-android emoji--confused" style="height:1.4em;width:auto;vertical-align:middle" title=":-\" alt="😕" /></li>
</ul>
<p dir="auto">So, can someone help me on how to get an png-File on the Server into the ImageLibrary?</p>
<p dir="auto">Thanks<br />
Andy</p>
<p dir="auto">Edit:</p>
<p dir="auto">Ok, got it working.</p>
<pre><code>String objectName = (String)object1.getObjectName();
String fileName = "C:/Users/xxx/Images/" + objectName + ".PNG";
UUID uuid = UUID.randomUUID();
ProgressListener listener = null;
byte[] array = Files.readAllBytes(new File(fileName).toPath());

LibraryImage newImg = new LibraryImage(uuid, objectName, "Default", "image/png", false);
newImg.setBinaryData(array);
s.createImage(newImg, listener);
</code></pre>
<p dir="auto">Only Problem now, it takes some time until i can assign the new Image to a Node.</p>
]]></description><link>https://forum.netxms.org/topic/5128/add-image-to-library-via-java-api</link><generator>RSS for Node</generator><lastBuildDate>Fri, 13 Nov 2026 13:58:55 GMT</lastBuildDate><atom:link href="https://forum.netxms.org/topic/5128.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 04 Jul 2017 06:44:01 GMT</pubDate><ttl>60</ttl></channel></rss>