From 4193921b4e03dfb40f3d7bdb5e7ddb385ae610af Mon Sep 17 00:00:00 2001 From: Bobby Wibowo Date: Sun, 9 Dec 2018 01:01:08 +0700 Subject: [PATCH] Updated uploadController.js The GET task of URL uploads will now limit the maximum size of the response body by the size reported in Content-Length header of the HEAD task. This relies on node-fetch's way of handling it. I don't know the magic behind it. --- controllers/uploadController.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/controllers/uploadController.js b/controllers/uploadController.js index 145c621..422406f 100644 --- a/controllers/uploadController.js +++ b/controllers/uploadController.js @@ -261,7 +261,9 @@ uploadsController.actuallyUploadByUrl = async (req, res, user, albumid) => { return erred('File too large.') } - const fetchFile = await fetch(url) + const fetchFile = await fetch(url, { + size // limit max response body size with content-length + }) if (fetchFile.status !== 200) { return erred(`${fetchHead.status} ${fetchHead.statusText}`) }