MATLAB Answers

Downloading a zipped file from S3 via AWS

22 views (last 30 days)
John Spicer
John Spicer on 18 Jul 2019
We're trying to download files (one at a time) from AWS S3.
I've used the example code I found on the web to get the list of files (works great), and I am trying to use this code to fetch the file:
fp= ['s3://ourBucketGoesHere/‘ selectedFile];
ds=fileDatastore(fp,'ReadFcn',@AWSRead, 'FileExtensions', {'.zip','','.txt'});
mydata=ds.read;
saveName = [filename ext];
save (saveName, 'mydata');
(also use this function for actual fetching) ->
function data = AWSRead(fileName)
fid = fopen(fileName);
data= fread(fid,inf);
fclose(fid);
end
Which does fetch the file.
The problem is that I can't save it in a format recognized. It should be gzip format (as it is coming from the server) but I can't make it work.
It's probably a setting I have wrong, I expect. Searching the net didn't find anything.

  0 Comments

Sign in to comment.

Answers (0)

Tags

Products


Translated by