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.
This commit is contained in:
Bobby Wibowo 2018-12-09 01:01:08 +07:00
parent 742ae43622
commit 4193921b4e
No known key found for this signature in database
GPG Key ID: 51C3A1E1E22D26CF

View File

@ -261,7 +261,9 @@ uploadsController.actuallyUploadByUrl = async (req, res, user, albumid) => {
return erred('File too large.') 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) { if (fetchFile.status !== 200) {
return erred(`${fetchHead.status} ${fetchHead.statusText}`) return erred(`${fetchHead.status} ${fetchHead.statusText}`)
} }