How do I save data from a Web App into a local file ?
68 views (last 30 days)
I would like to convert a number of our company XLS Spreadsheets into Web Apps but I need to be able to save and load data input by the user to a local file (i.e. csv or even text will do). I notice there are limitations with Web Apps (saving, printing etc)but apparently it can be done using the following advice
"As a workaround, MATLAB file I/O functions such as readtable, load, and fread will work if the file or folder is on a network location accessible by both the client and server"
I have tried using writetable but no file is created and the web app log reports it is unable to open the file and also reports permission denied. Has anyone else tried this and perhaps have some sample code that may work for a Web App ? Any help appreciated. I am using ver R2018a
Igor Kuklin on 5 Sep 2018
Edited: Igor Kuklin on 5 Sep 2018
In 18a, MATLAB Web Apps service runs under MATLABWebAppsGuest account, unless you chose some other account during service installation. You need to login into server machine and give read permission to c:\temp (or any other directory) to this account using Windows Explorer so it will be able to work with it. Choose directory properties, "Security" tab, then click on "Edit" button. On that screen, add mentioned user account via "Add" button and make sure it has needed permissions.
To be able to upload files to the web app server from the local network, you will need to share this directory. Using Windows Explorer on the server, choose directory properties, "Sharing" tab, then "Advanced Sharing". Check "Share this folder". Then click on "Permissions" button and review who can write into this directory from the network.
After this, you will be able to copy files to the server shared directory and they will be accessible to server applications via server path like "c:\temp".
Kojiro Saito on 14 Sep 2018
I know you're using R2018a, and this is just information. From R2018b, uigetfile and uiputfile are supported in WebApps, so you can upload files to and download from WebApps.
Chris Portal on 2 Sep 2018
In R2018a, this would only be possible if you specify a network path to the WRITETABLE command for it to produce the file at that location. Note, the web apps server would need to have permissions to access this network location. This is the only way to workaround the limitation for now. The file IO workflow will be more directly supported in an upcoming release.
Keerthana Chivukula on 14 Sep 2018
Edited: Keerthana Chivukula on 14 Sep 2018