How do I save data from a Web App into a local file ?

56 views (last 30 days)
Hi,
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
Richard

Answers (5)

Igor Kuklin
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
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.
  3 Comments
Richard Merifield
Richard Merifield on 24 Oct 2018
Thank for this. It is a shame the download dialog box only gives you the option to "download" using the browser and not the "save" button like the standalone app version.

Sign in to comment.


Chris Portal
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.
  3 Comments
Varun Gandhi
Varun Gandhi on 7 Jun 2019
Hi Alexander,
Web apps pose a security challenge between server-client communications and file system access. In order to insulate MATLAB App Authors from this we have enabled the workflows for UIGETFILE/UIGETDIR to work differently when used in a deployed web app.
I do not expect these tools (or UIGETDIR) to be able to access and present the end-users' file system any time soon.
One workaround I can offer is to use one of our existing UI components to create a directory selector/browser or list predefined directories that you know both the web app server and users will have access to.
For example: you can use a UITree to show the directory or a uidropdown for users to type in a known path. Then "Save/Save As" operations can simply do the opposite thing and write out to the known network directory the the end-user selects via another affordance.
Varun
Alexander Mueller
Alexander Mueller on 7 Jun 2019
Varun,
Thanks for the reply. I will investigate rolling my own UIGETDIR-like directory chooser since I know the path to the secure area that users and app have access to.
If you find someone has already built one of these please do pass it along.
Thanks
AM

Sign in to comment.


Richard Merifield
Richard Merifield on 5 Sep 2018
Thanks Chris, I have tried the WRITETABLE command with limited success. On the PC that is running the Matlab Web Server I can save to C:\Temp from the web app that takes the path from an edit box, but nowhere else on the PC (not mapped network drives also). On a remote PC I cannot even seem to write to C:\Temp, the log indicates write/access permission errors? How can you change permissions for the web app server?
Regards
Richard

Keerthana Chivukula
Keerthana Chivukula on 14 Sep 2018
Edited: Keerthana Chivukula on 14 Sep 2018

Categories

Find more on MATLAB Web App Server in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!