I'm a beginner to aws s3 and I am trying to read a pretty large file (250mb) from S3 using JavaScript when I run localhost:8000
.
I followed examples and wrote code that should retrieve data. But so far, it doesn't even go inside s3.getObject()
function (no error message, no data returned). I think there's something failing right when it tries s3.getObject()
. I'm not sure if it's because of authorization problem or if the file is too big. Or is there're any other issues I'm not aware of?
More specifically, I've been using the following code. s3.getObject()
is called inside a middleware. I do get print messages of params:
but do not get a print message of --- err:
or --- data:
, which indicates that there's something failing right when it tries s3.getObject
.
const aws = require('aws-sdk');
const s3 = new aws.S3({ accessKeyId: 'directly wrote ID for now', secretAccessKey: 'directly wrote secretKey' });
module.exports.getData = (req, res, next) => {
let getParams = {
Bucket: 'bucket-name',
Key: 'file-name'
};
console.log('params: ', getParams);
s3.getObject(getParams, function(err, data) {
console.log('--- err: ', err);
console.log('--- data: ', data);
req.myData = data;
next();
});
};
I want to see either error message or data inside s3.getObject()
.
Update
I added a test file that's very small and now I was able to read the file. So the problem is due to the size of the file... Any recommendation to handle large file reading?