Filter löschen
Filter löschen

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

43 Ansichten (letzte 30 Tage)
Richard Merifield
Richard Merifield am 9 Aug. 2018
Verschoben: Angelo Yeo am 9 Jul. 2024 um 23:34
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

Antworten (3)

Igor Kuklin
Igor Kuklin am 5 Sep. 2018
Bearbeitet: Igor Kuklin am 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 am 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 Kommentare
Kojiro Saito
Kojiro Saito am 21 Okt. 2018
I've shared a sample demo as an answer to your question ( https://www.mathworks.com/matlabcentral/answers/425165)
Richard Merifield
Richard Merifield am 24 Okt. 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.

Melden Sie sich an, um zu kommentieren.


Chris Portal
Chris Portal am 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.
  4 Kommentare
Varun Gandhi
Varun Gandhi am 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 am 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

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu MATLAB Web App Server finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by