Node aws-sdk s3 file upload options

When using the aws-sdk npm module for nods.js, I can download pdf at 50kb with the following code (in AWS s3):

var params = { Bucket: BUCKET, Key: pdf_key, Body: file, ContentType: 'application/pdf' }; var s3 = new AWS.S3(); s3.putObject(params, function(error, data) { console.log(data); console.log(error); if (error) { console.log(error); callback(error, null); } else { callback(null, pdf_key); } }); 

But when downloading 11mb pdf, even with ContentLength , the download just continues forever, even with a 2 minute timeout.

The question is, how to get aws s3 to accept a large PDF file?

UPDATE

I have not yet found any documentation or an under for the question.

UPDATE 2

I will accept answers that show one structure or another that can do this. I will need this framework to be able to also allow auth-reading of an object.

UPDATE 3 I have earned it now, but I have not found a reason why it should not work.

Thanks in advance!

+6
source share
1 answer

Connecting to S3 is not fast, and then, depending on network fluctuations, you can get timeouts and other strange behaviors.

The code you provided is great, but you can use multi-page downloads that could solve the problems, especially s> 5 MB files.

I made a rough implementation of multi-page download , and also made an attempt to retry downloading any faulty part up to 3 times, this will also work for smaller files than 5 MB.

+7
source

Source: https://habr.com/ru/post/947370/


All Articles