anacronw / multer-s3

multer storage engine for amazon s3
MIT License
660 stars 190 forks source link

Upload hangs #99

Closed DecathectZero closed 3 years ago

DecathectZero commented 6 years ago

I've been trying to use multer-s3 to create a dropbox like service where users can upload their files and download them later. I've noticed that when uploading files of sizes around 30MB or larger the entire upload (based on the client side progress bar) just hangs and freezes and never makes any more progress. But it works perfectly fine for smaller sized files.

This problem only occurs on my remote production server as well. When on localhost the upload goes smoothly.

My code looks something like this

const upload = multer({
    storage: multerS3({
        s3: s3,
        bucket: bucket,
        acl: 'public-read',
        contentDisposition: function (request, file, cb) {
            cb(null, "filename=" + encodeURIComponent(file.originalname));
        },
        key: function (request, file, cb) {
            let hash = app.locals.generateHash(16);
            cb(null, hash);
        }
    }),
    limits: { fileSize: maxFileSize }
}).array("files", 20);`
app.post('/upload/:sender_id/:receiver_id', function(req, res){
    upload(req, res, function(err){
        res.sendStatus(200);
        } 
});

After some further testing and debug messages, I've noticed that this only occurs for large files

Jac0xb commented 6 years ago

This is similar to https://github.com/badunk/multer-s3/issues/69, there is a possible solution to your problem.

LinusU commented 3 years ago

69 holds the solution 👍