# Need help writing and image file to a mapped drive on the gateway

**URL:** <https://forum.inductiveautomation.com/t/need-help-writing-and-image-file-to-a-mapped-drive-on-the-gateway/69722>\
**Category:** Ignition\
**Tags:** ignition81, scripting, perspective\
**Created:** [February 10, 2023, 9:49pm UTC](https://forum.inductiveautomation.com/t/need-help-writing-and-image-file-to-a-mapped-drive-on-the-gateway/69722 "2023-02-10T21:49:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gratliff](https://avatars.discourse-cdn.com/v4/letter/g/a5b964/32.png) [@Gratliff](https://forum.inductiveautomation.com/u/Gratliff)\
**Post date:** [February 10, 2023, 9:49pm UTC](https://forum.inductiveautomation.com/t/need-help-writing-and-image-file-to-a-mapped-drive-on-the-gateway/69722/1 "2023-02-10T21:49:42Z")

</div>

I have a project where users can upload an image that gets stored to both a SQL database, and to a drive on the gateway. Later, we use a mounted folder to serve the images that are stored on the drive. Then we display those images in a web page created by a WebDev, python resource. For reasons I won' t go into, we don't want to pull these images from the database for display.

All of this works fine if the drive is local to the gateway. We prefer not to store the images directly on the gateway's drive though as we don't want to use space on the VM for this reason. We would prefer to map a drive on the gateway to a NAS and store the files on the mapped drive. This is where the problem arises.

When we run this script on the upload component (in Perspective):

> def runAction(self, event):  
> fileName = event.file.name  
> #path = "C://ExpenseReceipts/" + fileName  
> path = "X://expenseReceipts/" + fileName  
> system.file.writeFile(path, event.file.getBytes())

The commented line to the C:\ drive above works like we expect. The uncommented line to the X:\ drive does not. The X:\ drive is the mapped drive.

Both of these drives have been created as WebDev mounted folders.

The error returned in the log is:

> Error running action 'component.onFileReceived' on JMS/Expenses/test@C/root/FileUpload: Traceback (most recent call last): File "function:runAction", line 5, in runAction IOError: Unable to create path to file 'X:\expenseReceipts\myFile.pdf'

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [February 10, 2023, 11:32pm UTC](https://forum.inductiveautomation.com/t/need-help-writing-and-image-file-to-a-mapped-drive-on-the-gateway/69722/2 "2023-02-10T23:32:00Z")

</div>

Add the map to the Ignition conf, this will require a reboot to take effect

[https://docs.inductiveautomation.com/display/DOC81/Mapping+a+Network+Drive](https://docs.inductiveautomation.com/display/DOC81/Mapping+a+Network+Drive)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 10, 2023, 11:41pm UTC](https://forum.inductiveautomation.com/t/need-help-writing-and-image-file-to-a-mapped-drive-on-the-gateway/69722/3 "2023-02-10T23:41:13Z")

</div>

> [@Gratliff](#):
>
> We would prefer to map a drive on the gateway to a NAS and store the files on the mapped drive.

Note that if your NAS is not available at the time Ignition starts or restarts, it won't ever connect without another restart.

Mapping network drives for background services is a kludge.

> [@Gratliff](#):
>
> For reasons I won' t go into, we don't want to pull these images from the database for display.

You should revisit this, or:

Put a reverse proxy in front of Ignition that can divert requests for the folder of images to another webserver that has direct access to the files.

Or, switch to an operating system that can provide network filesystems to background services without drama.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [February 11, 2023, 11:41pm UTC](https://forum.inductiveautomation.com/t/need-help-writing-and-image-file-to-a-mapped-drive-on-the-gateway/69722/4 "2023-02-11T23:41:01Z")

</div>

You could also use a UNC path instead of a mapped drive

---

<div class="post-metadata">

**Author:** ![Gratliff](https://avatars.discourse-cdn.com/v4/letter/g/a5b964/32.png) [@Gratliff](https://forum.inductiveautomation.com/u/Gratliff)\
**Post date:** [February 12, 2023, 1:26pm UTC](https://forum.inductiveautomation.com/t/need-help-writing-and-image-file-to-a-mapped-drive-on-the-gateway/69722/5 "2023-02-12T13:26:05Z")

</div>

I completely forgot this step. Thank you! We can now write to the share.
