1 import { remove } from 'fs-extra'
2 import { join } from 'path'
3 import { processImage } from '@server/helpers/image-utils'
4 import { doRequestAndSaveToFile } from '@server/helpers/requests'
5 import { CONFIG } from '@server/initializers/config'
7 async function downloadImage (options: {
11 size: { width: number, height: number }
13 const { url, destDir, destName, size } = options
15 const tmpPath = join(CONFIG.STORAGE.TMP_DIR, 'pending-' + destName)
16 await doRequestAndSaveToFile(url, tmpPath)
18 const destPath = join(destDir, destName)
21 await processImage({ path: tmpPath, destination: destPath, newSize: size })
29 module.exports = downloadImage