How to upload a .mat file into Amazon s3

12 ビュー (過去 30 日間)
NANDITA SHARMA
NANDITA SHARMA 2020 年 12 月 7 日
コメント済み: VISHNUDAS V U 2021 年 6 月 6 日
I have stored my data into .mat file and want to upload it into Amazon s3 cloud using MATLAB. I can upload it using command prompt using "aws s3 cp local_path cloud_path" command but can't using MATLAB. So how to upload the file using MATLAB.

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 12 月 7 日
You can use API to write the data: https://www.mathworks.com/help/matlab/ref/webwrite.html, but that can get complicated for AWS S3.
The easiest solution might be just to use the system() function: https://www.mathworks.com/help/matlab/ref/system.html. You can just run the shell command from MATLAB
system('aws s3 cp local_path cloud_path')
However, note that it does not use the same $PATH variable as your default shell. You will need to use setenv() to add another directory to $PATH variable, or you will need to specify the complete path to aws binary, for example
system('/usr/local/bin/aws s3 cp local_path cloud_path')
There seem to be some options for uploading the file using MATLAB too: https://www.mathworks.com/help/matlab/import_export/work-with-remote-data.html
  3 件のコメント
Ameer Hamza
Ameer Hamza 2020 年 12 月 10 日
編集済み: Ameer Hamza 2020 年 12 月 11 日
The method using system command will only work on the local machine. MATLAB online does not have aws command-line tools. For MATLAB online, you might need to use the last option I described.
VISHNUDAS V U
VISHNUDAS V U 2021 年 6 月 6 日
Can you please tell how to obtain local_path and cloud_path .Like what will be its format with a simple example?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePlatform and License についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by