Borrar filtros
Borrar filtros

MATLAB Web App Server 上で動作するアプリか​らファイルをダウンロ​ードするにはどうすれ​ばよいですか?

5 visualizaciones (últimos 30 días)
MathWorks Support Team
MathWorks Support Team el 22 de Ag. de 2024 a las 0:00
Respondida: MathWorks Support Team el 22 de Ag. de 2024 a las 8:01

サーバーマシン上の MATLAB Web App Server で複数の Web アプリを実行しています。ユーザーが Web アプリからローカルマシンにファイルをダウンロードする方法を検討中です。しかし、save や exportgraphics などの関数を使用すると、ファイルはサーバーマシンに出力されます。
Web アプリからユーザーのローカルマシンにファイルを保存するにはどうすればよいでしょうか。

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 22 de Ag. de 2024 a las 0:00
Web アプリからクライアントマシンにファイルを保存するには、uiputfile を使用してダウンロード場所へのパスを取得します。このパスを save、exportgraphics などの関数にてファイルの保存先として使用することによりユーザー用のファイルをダウンロードできます。
たとえば、アプリの app.UIAxes コンポーネントに現在表示されているグラフを .PNG ファイルとして保存するには、 次のようにします。
% Get the path to the download location  [f, p] = uiputfile('*.png'); % Save the plot to the specified path exportgraphics(app.UIAxes,fullfile(p,f));
複数のファイルを一度にダウンロードする場合は zip コマンドを使用してファイルを 1 つの .ZIP ファイルに圧縮し、これをクライアントマシンに保存します。
% Get the path to the download location [f, p] = uiputfile('*.zip'); % Zip 3 files and save them to the specified path zip(fullfile(p,f),{'file1.mat','file2.mat','file3.mat'});
注意すべき追加の点がいくつかあります。
  • Web アプリからダウンロードしたファイルは、常にクライアント ブラウザーで指定されたダウンロード場所に配置されます。ユーザーはuiputfileダイアログボックスでファイル名を指定できますが、保存先フォルダはブラウザの設定からのみ変更できます。
  • Web アプリがアプリの検索パスに沿っていない (つまり、アプリ/セッション キャッシュの外部) サーバー コンピューター上のファイルを参照している場合は、アプリ サービスがこれらのファイルにアクセスできることを確認してください。(https://jp.mathworks.com/help/webappserver/ug/set-up-matlab-web-app-server.html#mw_9d711692-de48-492d-902e-95d0c3f09fc2)
  • uiputfileuigetfile は Web アプリとの間でのファイルの受け渡しに対応していますが、uigetdir 関数は Web アプリでの使用はサポートされていません。(https://jp.mathworks.com/help/webappserver/ug/unsupported-functionality.html#mw_6b3fd2a9-b7e8-4565-96c5-95859eaa9f99)

Más respuestas (0)

Categorías

Más información sobre MATLAB Web App Server en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!