system.file.writeFile in perspective

Does writeFile() work in perspective for the session? I’m able to get a file to write from a gateway message relative to the gateway folder structure, but when I try to use the session with a static file path I don’t get an error in the log but I also don’t get the file.

Are you looking locally, or on the Gateway? The function is available in Perspective, but all Perspective scripts run on the Gateway, so that is where the write would be occurring.

What’s the recommended way to pull the file local? Is there a mechanism for that?

There is no current mechanism for local file manipulation. The first incoming component will be a File Upload Component to allow for Sessions to upload file(s) to the Gateway.

Any localized file manipulation is still best handled by using the Vision Client.

For your original post, did you locate the file on the Gateway?

When I executed it within the session no, when I did it from a Gateway Message yes.

What is the release schedule for this functionality? Is this component designed to be used in such a way that the actual file saving mechanism can be implemented with a script(E.g. above-mentioned system.file.writeFile) or are the uploaded files saved straight to (internal?)database?

With our new release cycle, I believe the component should be available in 8.0.1 (which would be early-to-mid May).

My understanding is that the component does not create files locally OR remotely, it only takes an existing file and sends it to the Gateway’s file system (NOT the database). The designer would be able to configure the location of incoming files within a declared directory, but I don’t know what that directory is at this time.

I can confirm that the just-posted 8.0.1 nightly has a File Upload component with an onFileReceived event. The event isn’t documented yet, but some peeping into it shows that it currently has an event.file class that has name and size attributes, and getBytes(), copyTo(path), inputStream(), and outputStream() methods, all of which appear to work as expected.

Obviously, this is subject to change at any time.

For file download, I think you might be better off generating a file to a regular webserver (we host both on the same system, so it’s not hard) and then use system.perspective.navigate to prompt to download from the new url.

Edit: Changelog just got posted and documented it (sans a few other functions I found available), haha.

Another entirely-Ignition solution would be the webdev module, but yes, this is absolutely correct.

1 Like

Ohhhh, so that's what that's for. Makes sense, and a lot less overhead than setting up a separate IIS/nginx, too.