+async function downloadImage (url: string, destDir: string, destName: string, size: { width: number, height: number }) {
+ const tmpPath = join(CONFIG.STORAGE.TMP_DIR, 'pending-' + destName)
+ await doRequestAndSaveToFile({ method: 'GET', uri: url }, tmpPath)
+
+ const destPath = join(destDir, destName)
+
+ try {
+ await processImage(tmpPath, destPath, size)
+ } catch (err) {
+ await remove(tmpPath)
+
+ throw err
+ }
+}
+
+function getUserAgent () {
+ return `PeerTube/${PEERTUBE_VERSION} (+${WEBSERVER.URL})`
+}
+