Trying to fix bug :")
This commit is contained in:
parent
3a88d983fc
commit
9203335963
1 changed files with 19 additions and 15 deletions
34
libs.js
34
libs.js
|
@ -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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue