How to load or display content of the file from AWS S3
31 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Mukesh Dangi
el 29 de Jun. de 2018
Respondida: Mukesh Dangi
el 3 de Jul. de 2018
I have following code which load files from AWS s3 however i'm not sure how to display os access the these files one by one: -
%Set S3 Credentials
setenv('AWS_ACCESS_KEY_ID', '{ID}');
setenv('AWS_SECRET_ACCESS_KEY','{KEY}');
setenv('AWS_REGION', 'us-east-1');
%Load Data
imds = fileDatastore('s3://{bucket}/',...
'FileExtensions',{'.txt', '.pdf'},...
'ReadFcn',@load,...
'IncludeSubfolders',true);
file=imds;
disp(file);
output
FileDatastore with properties:
Files: {
's3://{bucket}/2017%20EBA%20-%20Relets%20(part%201)%20-%20signed.pdf'
's3://{bucket}/AQS94%20-%20Official%20Website.pdf'
's3://{bucket}/summary.txt'
}
UniformRead: 0
ReadFcn: @load
AlternateFileSystemRoots: {}
I tried
file=imds.Files;
disp(file);
However it's not displaying the content of the file.
0 comentarios
Respuesta aceptada
Más respuestas (1)
Hatem Helal
el 2 de Jul. de 2018
You need to call read on the datastore. Its hard to make a specific recommendation, but if your goal is to open the txt and pdf files in your S3 bucket locally: you could try using the open command instead of load as the ReadFcn of your fileDatastore. Something like the following
fds = fileDatastore('s3://{bucket}/',...
'FileExtensions',{'.txt', '.pdf'},...
'ReadFcn',@open,...
'IncludeSubfolders',true);
while hasdata(fds)
read(fds)
end
1 comentario
Ver también
Categorías
Más información sobre Data Import and Analysis en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!