Perspective - FileUpload - Webdev

I’m on 8.1.5

I try to set my onFileReceived to save the file in a webdev mounted path.

When I try with the webserver/webapps/main the file is saved correctly.

For testing i have mounted a webdev path (my_path) to the C:\Program Files\Inductive Automation\Ignition\webserver\webapps\main\ folder and it doesn’t work, in the Log I have an error “folfer don’t find”

	filePath = "system/webdev/my_path/" + event.file.name
	event.file.copyTo(filePath)

log:
Error running action ‘component.onFileReceived’ on 1-UDTS/UTILS/main@C/root/FileUpload: Traceback (most recent call last): File “function:runAction”, line 4, in runAction at java.base/java.io.FileOutputStream.open0(Native Method) at java.base/java.io.FileOutputStream.open(Unknown Source) at java.base/java.io.FileOutputStream.(Unknown Source) at java.base/java.io.FileOutputStream.(Unknown Source) at com.inductiveautomation.perspective.gateway.components.common.UploadedFile.copyTo(UploadedFile.java:57) at jdk.internal.reflect.GeneratedMethodAccessor83.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) java.io.FileNotFoundException: java.io.FileNotFoundException: system\webdev\my_path\test.xml (Le chemin d’accès spécifié est introuvable)

I think the webdev directory is project-specific. try

filePath = "system/webdev/project_name/my_path/" + event.file.name
event.file.copyTo(filePath)

Doesn't work, same error
Error running action 'component.onFileReceived' on 1-UDTS/UTILS/main@C/root/FileUpload: Traceback (most recent call last): File "function:runAction", line 4, in runAction at java.base/java.io.FileOutputStream.open0(Native Method) at java.base/java.io.FileOutputStream.open(Unknown Source) at java.base/java.io.FileOutputStream.(Unknown Source) at java.base/java.io.FileOutputStream.(Unknown Source) at com.inductiveautomation.perspective.gateway.components.common.UploadedFile.copyTo(UploadedFile.java:57) at jdk.internal.reflect.GeneratedMethodAccessor83.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) java.io.FileNotFoundException: java.io.FileNotFoundException: system\webdev\AMT\my_path\test.xml (Le chemin d’accès spécifié est introuvable)

I think there’s a fundamental misunderstanding as to what the path for the mounted resource and the path of the copyTo() method are supposed to be going. Both of those paths are supposed to be directory paths not URL paths.
Here’s a simple project to help follow what I am saying
mountedTest.zip (9.7 KB)
If you check the mounted folder resource, you will see it’s path is ./data which is the data directory on the gateway’s install location. This makes it so that any files stored there can be accessed by the URL path http://<gateway_ip:port>/system/webdev/<project_name>/mounted_path/<resource_name>

Now if you go to the Perspective view and check the FileUpload component’s onFileRecieved event, you will see it’s just: event.file.copyTo('./data/'+event.file.name) which will take the file and place it in that mounted data folder.

These together make it so that if you upload a file, you can go to your browser and navigate to http://<gateway_ip:port>/system/webdev/<project_name>/mounted_path/<resource_name> and see your resource displayed on the browser. That URL path can also be used for other components that require some sort of URL path or even for http bindings.

BIG NOTE: Do not use ./data as your mounted folder path. This exposes the entirety of that folder to your gateway’s web API which you probably don’t want. You’ll probably want to make your own custom directory instead.

OK, now I undertans better the mounted path.

Is it possible to save files on a file server outside of the gateway ?

I believe I’ve seen others on this forum use a network folder that the gateway has access to used for this reason. I have not tried it myself but it should be as easy as setting up the networked folder between the gateway and your file server, then setting that networked folder as your WebDev mounted folder in your project.