Trying to fix bug :")

This commit is contained in:
dbroqua 2020-03-30 21:53:17 +02:00
parent 3a88d983fc
commit 9203335963

34
libs.js
View file

@ -213,22 +213,26 @@ const getMedia = (coverUrl, callback) => {
const dest = '/tmp/attachment.jpg' const dest = '/tmp/attachment.jpg'
const file = fs.createWriteStream(dest) const file = fs.createWriteStream(dest)
request({ try {
uri: coverUrl, request({
headers: { uri: coverUrl,
'Cache-Control': 'max-age=0', headers: {
Connection: 'keep-alive', 'Cache-Control': 'max-age=0',
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36' Connection: 'keep-alive',
} 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36'
}) }
.pipe(file)
.on('finish', () => {
callback(null, dest)
})
.on('error', (error) => {
console.log(config.colors.FgRed, 'ERR:', error, config.colors.Reset)
callback(error)
}) })
.on('error', (error) => {
console.log(config.colors.FgRed, 'ERR:', error, config.colors.Reset)
callback(error)
})
.pipe(file)
.on('finish', () => {
callback(null, dest)
})
} catch (error) {
callback(error)
}
} }
/** /**