Trying to fix bug :")
This commit is contained in:
parent
3a88d983fc
commit
9203335963
1 changed files with 19 additions and 15 deletions
12
libs.js
12
libs.js
|
@ -213,6 +213,7 @@ const getMedia = (coverUrl, callback) => {
|
|||
const dest = '/tmp/attachment.jpg'
|
||||
const file = fs.createWriteStream(dest)
|
||||
|
||||
try {
|
||||
request({
|
||||
uri: coverUrl,
|
||||
headers: {
|
||||
|
@ -220,15 +221,18 @@ const getMedia = (coverUrl, callback) => {
|
|||
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)
|
||||
})
|
||||
.pipe(file)
|
||||
.on('finish', () => {
|
||||
callback(null, dest)
|
||||
})
|
||||
} catch (error) {
|
||||
callback(error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue