Updated uploadController.js

Added DuckDuckGo's proxy support for "Upload by URLs". Make sure you add the new option in config.sample.js into your config.js.

This may be considered a hack and not supported by DuckDuckGo, so USE AT YOUR OWN RISK.

Credits to Proxy#1337.
This commit is contained in:
Bobby Wibowo 2018-06-06 00:16:41 +07:00
parent 369b1137a7
commit 57834dd362
No known key found for this signature in database
GPG Key ID: 51C3A1E1E22D26CF
2 changed files with 13 additions and 1 deletions

View File

@ -84,6 +84,13 @@ module.exports = {
*/
urlMaxSize: '32MB',
/*
Use DuckDuckGo's proxy when fetching any URL uploads.
This may be considered a hack and not supported by DuckDuckGo, so USE AT YOUR OWN RISK.
This have only been tested with pictures, GIFs, WEBMs and MP4s.
*/
urlDuckDuckGoProxy: false,
/*
Chunk size for chunk uploads. Needs to be in MB.
If this is enabled, every files uploaded from the homepage uploader will forcibly be chunked

View File

@ -198,9 +198,14 @@ uploadsController.actuallyUploadByUrl = async (req, res, user, albumid) => {
if (!config.uploads.urlMaxSize) { return erred('Upload by URLs is disabled at the moment.') }
const urls = req.body.urls
let urls = req.body.urls
if (!urls || !(urls instanceof Array)) { return erred('Missing "urls" property (Array).') }
// DuckDuckGo's proxy
if (config.uploads.urlDuckDuckGoProxy) {
urls = urls.map(url => `https://proxy.duckduckgo.com/iur/?f=1&image_host=${encodeURIComponent(url)}&u=${url}`)
}
let iteration = 0
const infoMap = []
for (const url of urls) {