Hi Raffaele,
I have attached a code snippet for a custom panel that saves a local image from an HTTP URL.
This example uses an ogScript.asyncHTTP() command to retrieve the image and a callback function is triggered to save the file. The ogscript.saveToFile() command accepts a boolean argument which can be set to true in order to overwrite the file if it already exists.
Please let me know if you have any questions.
<abs contexttype="opengear" gridsize="20" id="_top" keepalive="false" style="">
<meta>
<params>
<param access="1" maxlength="0" name="url" oid="url" type="STRING" value="https://2wk12w2dk3733zyjdf3secd9-wpengine.netdna-ssl.com/wp-content/uploads/2018/03/Ross-Logo-Living-Live.png" widget="default"/>
<param access="1" maxlength="0" name="filename" oid="filename" type="STRING" value="ross.png" widget="file-picker"/>
</params>
<api>
</api>
</meta>
<label height="80" left="40" name="Using a URL for an image" style="txt-align:west;size:Bigger;" top="20" width="520"/>
<button buttontype="push" height="100" left="40" style="bg-u:https://2wk12w2dk3733zyjdf3secd9-wpengine.netdna-ssl.com/wp-content/uploads/2018/03/Ross-Logo-Living-Live.png;bg-fill:fit;bg-insets:10,10,10,10;" top="100" width="200"/>
<label height="80" id="" left="40" name="Saving a URL image to file" style="txt-align:west;size:Bigger;" top="280" width="540"/>
<table height="40" left="40" oid="url" top="360" width="660">
<tr>
<label anchor="east" fill="none" insets="0,0,0,5" name="url" weightx="0.0"/>
<param anchor="west" expand="true" fill="both" oid="url" showlabel="false" weightx="1.0" weighty="1.0"/>
</tr>
</table>
<table height="40" left="40" oid="filename" top="420" width="660">
<tr>
<label anchor="east" fill="none" insets="0,0,0,5" name="filename" weightx="0.0"/>
<param anchor="west" expand="true" fill="both" oid="filename" showlabel="false" weightx="1.0" weighty="1.0"/>
</tr>
</table>
<button buttontype="push" height="40" left="40" name="Save" top="480" width="140">
<task tasktype="ogscript">
function callbackGetUrl(resultStr)
{
ogscript.debug("resultStr is " + resultStr);
ogscript.saveToFile(params.getValue('filename', 0), resultStr, false);
ogscript.rename("savemessage", "url saved to " + params.getValue('filename',0));
}
ogscript.asyncHTTP(params.getValue('url', 0), 'GET', null, null, callbackGetUrl, false);</task>
</button>
<label height="40" id="savemessage" left="200" name="" style="txt-align:west;" top="480" width="500"/>
</abs>
#DashBoard