How do I save data from a Web App into a local file ?
26 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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
0 Commenti
Risposte (3)
Igor Kuklin
il 5 Set 2018
Modificato: Igor Kuklin
il 5 Set 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".
0 Commenti
Kojiro Saito
il 14 Set 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 Commenti
Kojiro Saito
il 21 Ott 2018
I've shared a sample demo as an answer to your question ( https://www.mathworks.com/matlabcentral/answers/425165)
Chris Portal
il 2 Set 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.
4 Commenti
Varun Gandhi
il 7 Giu 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
il 7 Giu 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
Vedere anche
Categorie
Scopri di più su MATLAB Web App Server in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!