How do I save data from a Web App into a local file ?
48 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(3 个)
Igor Kuklin
2018-9-5
编辑:Igor Kuklin
2018-9-5
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 个评论
Kojiro Saito
2018-9-14
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 个评论
Kojiro Saito
2018-10-21
I've shared a sample demo as an answer to your question ( https://www.mathworks.com/matlabcentral/answers/425165)
Chris Portal
2018-9-2
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 个评论
Varun Gandhi
2019-6-7
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
2019-6-7
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 MATLAB Web App Server 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!