I am using file upload component to upload file and i want to save uploaded file on default image folder (/system/images/). I wrote the following code on onFileReceived event in file upload component:
upload_path = ‘/system/images/’
system.util.getLogger(‘FILEUPLOAD’).info(‘Uploading: ‘{0}’ to directory ‘{1}’’.format(event.file.name, upload_path))
event.file.copyTo(upload_path + event.file.name)
This won’t work the way you’re expecting it to. The /system/images/ route handler isn’t attached to an actual folder in the gateway install directory - it’s handled entirely in code, and retrieves images from the internal database. If you want to manually upload images, you’ll need to get a reference to the ImageManager on the gateway and call insertImage manually, filling in all the appropriate fields: com.inductiveautomation.ignition.gateway.images.ImageManager#insertImage. Actually doing so is unsupported, so you’re entirely on your own to figure out the details. Some searching on the forum should tell you how to get the GatewayContext class, from which you can getImageManager.
I don’t think files placed there are placed into any recovery backup. Also, most of the time when you want to use a file after it’s been uploaded (like a profile picture for example), you would want to serve that file as a resource through the WebDev module, which is not what this route is doing; this route id just directly placing a file into the file system.
It's unsupported, because if you use it and something goes wrong, you're on your own. We never explicitly set out to make the webserver/webapps/main path automatically hosted - it's just a coincidence of the way we set up Jetty. Some future upgrade of Jetty may make that work differently, or we could explicitly gate the feature behind a config flag, or something.
In practice, because it's such an open secret, we'd probably take pains to prevent anything from breaking it upon such a hypothetical Jetty upgrade, but the reason we claim it's 'unsupported' is because you're basically relying on undefined Jetty behavior, not anything coded into Ignition deliberately.
I would need to see the actual error to have a better idea of what you're encountering. Please provide the stacktrace, relevant log line, or a screenshot of the error.