# system.file.writeFile in perspective

**URL:** <https://forum.inductiveautomation.com/t/system-file-writefile-in-perspective/23664>\
**Category:** Ignition Early Access\
**Created:** [March 27, 2019, 7:39pm UTC](https://forum.inductiveautomation.com/t/system-file-writefile-in-perspective/23664 "2019-03-27T19:39:32Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![christopher.green](https://avatars.discourse-cdn.com/v4/letter/c/b9bd4f/32.png) [@christopher.green](https://forum.inductiveautomation.com/u/christopher.green)\
**Post date:** [March 27, 2019, 7:39pm UTC](https://forum.inductiveautomation.com/t/system-file-writefile-in-perspective/23664/1 "2019-03-27T19:39:32Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [March 27, 2019, 7:45pm UTC](https://forum.inductiveautomation.com/t/system-file-writefile-in-perspective/23664/2 "2019-03-27T19:45:37Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![christopher.green](https://avatars.discourse-cdn.com/v4/letter/c/b9bd4f/32.png) [@christopher.green](https://forum.inductiveautomation.com/u/christopher.green)\
**Post date:** [March 27, 2019, 8:33pm UTC](https://forum.inductiveautomation.com/t/system-file-writefile-in-perspective/23664/3 "2019-03-27T20:33:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [March 27, 2019, 8:49pm UTC](https://forum.inductiveautomation.com/t/system-file-writefile-in-perspective/23664/4 "2019-03-27T20:49:19Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![christopher.green](https://avatars.discourse-cdn.com/v4/letter/c/b9bd4f/32.png) [@christopher.green](https://forum.inductiveautomation.com/u/christopher.green)\
**Post date:** [March 27, 2019, 8:52pm UTC](https://forum.inductiveautomation.com/t/system-file-writefile-in-perspective/23664/5 "2019-03-27T20:52:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![oskari.laaksonen](https://avatars.discourse-cdn.com/v4/letter/o/e47774/32.png) [@oskari.laaksonen](https://forum.inductiveautomation.com/u/oskari.laaksonen)\
**Post date:** [April 10, 2019, 9:29am UTC](https://forum.inductiveautomation.com/t/system-file-writefile-in-perspective/23664/6 "2019-04-10T09:29:02Z")

</div>

> [@cmallonee](#):
>
> The first incoming component will be a File Upload Component to allow for Sessions to upload file(s) to the Gateway.

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?

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [April 10, 2019, 2:00pm UTC](https://forum.inductiveautomation.com/t/system-file-writefile-in-perspective/23664/7 "2019-04-10T14:00:48Z")

</div>

With our new release [cycle](https://inductiveautomation.com/blog/all-aboard-the-release-train-first-stop-ignition-8), 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.

---

<div class="post-metadata">

**Author:** ![silverbacknet](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/silverbacknet/32/7385_2.png) [@silverbacknet](https://forum.inductiveautomation.com/u/silverbacknet)\
**Post date:** [April 10, 2019, 9:18pm UTC](https://forum.inductiveautomation.com/t/system-file-writefile-in-perspective/23664/8 "2019-04-10T21:18:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [April 11, 2019, 3:55pm UTC](https://forum.inductiveautomation.com/t/system-file-writefile-in-perspective/23664/9 "2019-04-11T15:55:43Z")

</div>

> [@silverbacknet](#):
>
> 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.

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

---

<div class="post-metadata">

**Author:** ![silverbacknet](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/silverbacknet/32/7385_2.png) [@silverbacknet](https://forum.inductiveautomation.com/u/silverbacknet)\
**Post date:** [April 11, 2019, 7:47pm UTC](https://forum.inductiveautomation.com/t/system-file-writefile-in-perspective/23664/10 "2019-04-11T19:47:42Z")

</div>

> [@paul-griffith](#):
>
> Another entirely-Ignition solution would be the webdev module, but yes, this is absolutely correct.

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