load .mat file fails in Web App

조회 수: 1 (최근 30일)
Deividas Eringis
Deividas Eringis 2021년 8월 13일
댓글: Deividas Eringis 2021년 8월 16일
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
Muhammed Yaseen
Muhammed Yaseen 2021년 8월 16일
편집: Muhammed Yaseen 2021년 8월 16일
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 2021년 8월 16일
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.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Web App Server에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by