How Do I dowload a file from Amazon S3?

6 次查看(过去 30 天)
Hello,
I am trying to use matlab to download a .gz file from Amazon s3. I have the AWS creditials set.
% Set AWS credentials
YOUR_AWS_ACCESS_KEY_ID = 'test1';
YOUR_AWS_SECRET_ACCESS_KEY = 'test2';
setenv('AWS_ACCESS_KEY_ID', YOUR_AWS_ACCESS_KEY_ID);
setenv('AWS_SECRET_ACCESS_KEY', YOUR_AWS_SECRET_ACCESS_KEY);
setenv('AWS_REGION', 'us-west-2');
I have my path s3 path:
rawdataPath = 's3://companya/Frontier/FieldData/file.csv.gz'
I am wondering how I can download this file.

回答(1 个)

Voss
Voss 2024-3-18
Once you have your environment set up, you should be able to treat files on S3 as you would treat any local file, e.g.,
rawdataPath = 's3://companya/Frontier/FieldData/file.csv.gz'
localDir = 'C:\Downloads';
% copy .gz to local directory:
copyfile(rawdataPath,localDir)
% or unzip .gz to local directory:
gunzip(rawdataPath,localDir)
  2 个评论
Matthew
Matthew 2024-3-18
when trying the copyfile() I get a low level error has occured.
Error using copyfile
A low level error has occurred at
's3://companya/Frontier/FieldData/file.csv.gz'.
Error in sc_downloadGZFiles (line 19)
copyfile(rawdataPath,Datapath);
When trying the gunzip() I get
Error using matlab.io.internal.archive.checkFilename>downloadArchiveFile
Function GUNZIP was unable to read URL
Voss
Voss 2024-3-18
Check that your AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are set correctly.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Programming Utilities 的更多信息

标签

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by