How Do I dowload a file from Amazon S3?

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.

Antworten (1)

Voss
Voss am 18 Mär. 2024

0 Stimmen

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 Kommentare

Matthew
Matthew am 18 Mär. 2024
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 am 18 Mär. 2024
Check that your AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are set correctly.

Melden Sie sich an, um zu kommentieren.

Kategorien

Produkte

Version

R2023b

Tags

Gefragt:

am 18 Mär. 2024

Kommentiert:

am 18 Mär. 2024

Community Treasure Hunt

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

Start Hunting!

Translated by