UNPKG

dbgate-api

Version:

Allows run DbGate data-manipulation scripts.

16 lines (13 loc) 441 B
const crypto = require('crypto'); const path = require('path'); const { uploadsdir } = require('../utility/directories'); const { downloadFile } = require('../utility/downloader'); async function download(url) { if (url && url.match(/(^http:\/\/)|(^https:\/\/)/)) { const tmpFile = path.join(uploadsdir(), crypto.randomUUID()); await downloadFile(url, tmpFile); return tmpFile; } return url; } module.exports = download;