load .mat file fails in Web App

1 visualizzazione (ultimi 30 giorni)
Deividas Eringis
Deividas Eringis il 13 Ago 2021
Commentato: Deividas Eringis il 16 Ago 2021
Hello,
i am trying to implement save/load functionality for a web app, everything works fine locally but load(filename) function fails on a web app,
%% Save Function
[file,path] = uiputfile('*.mat','Save patient data as .mat file')
if file~=0
resultFilePath = fullfile(path,file)
inputs={};
for i=1:numel(app.UIList)
inputs{i}=app.UIList{i}{2}.Data; % app.UIList{i}{2} are UITables
end
save(resultFilePath,'inputs','-v7','-nocompression')
end
%% Load Function
[file,pathn] = uigetfile('*.mat','File Selector');
disp(file)
disp(pathn)
if isequal(file,0)==false
inpuFilePath = fullfile(pathn,file)
try
Data=load(inpuFilePath);
inputs=Data.inputs;
%
%... CODE BLOCK FOR PROCESSING 'inputs'
%
catch ME
fprintf('error: \n');
fprintf('%s : %s\n',ME.identifier,ME.message);
fprintf('........\n');
fid=fopen(inpuFilePath);
dat=fread(fid,[1,90],'uint8');
fprintf('%s ',dat)
fprintf('\n')
end
end
Saving works fine, i get a file that i can load in matlab and everything is there, so the file is not corrupted, however when i load in web app, it says it is corrupted, why???
2021-08-13 10:51:47 test2.mat is uploaded successfully
2021-08-13 10:51:47 test2.mat
2021-08-13 10:51:47 /local/MathWorks/webapps/R2020b/USR/services/mdwas/sessions/8c115db5-9dc8-44be-88e6-928d4a4c6f89/1/
2021-08-13 10:51:48 inpuFilePath =
2021-08-13 10:51:48 '/local/MathWorks/webapps/R2020b/USR/services/mdwas/sessions/8c115db5-9dc8-44be-88e6-928d4a4c6f89/1/test2.mat'
2021-08-13 10:51:48 error:
2021-08-13 10:51:48 MATLAB:load:unableToReadMatFile : Unable to read MAT-file /local/MathWorks/webapps/R2020b/USR/services/mdwas/sessions/8c115db5-9dc8-44be-88e6-928d4a4c6f89/1/test2.mat. File might be corrupt.
2021-08-13 10:51:48 ........
2021-08-13 10:51:48 MATLAB 5.0 MAT-file, Platform: GLNXA64, Created on: Fri Aug 13 10:49:37 2021
  2 Commenti
Muhammed Yaseen
Muhammed Yaseen il 16 Ago 2021
Modificato: Muhammed Yaseen il 16 Ago 2021
I understand that you are unable to load a file which you have created in the Web app, but you are able to load it in MATLAB. Can you see if the following links can help?
Deividas Eringis
Deividas Eringis il 16 Ago 2021
i have seen the second link, that's why i did fread() to see if the file is there at all,
the first link is interesting it might be that there is an older runtime installed, i will contact my server administrator and check, thanks, i know for a fact that the oldest runtime installed could be 2019b which i would not expect to have problems loading .mat files.

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su MATLAB Web App Server in Help Center e File Exchange

Prodotti


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by