mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
fix: Handle data: URIs in getStream to prevent server crash (#1524)
This commit is contained in:
committed by
GitHub
parent
4ccec1f6ce
commit
92b4c68de0
@@ -317,7 +317,14 @@ export const getStream = async (item: WAMediaUpload, opts?: AxiosRequestConfig)
|
|||||||
return { stream: item.stream, type: 'readable' } as const
|
return { stream: item.stream, type: 'readable' } as const
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.url.toString().startsWith('http://') || item.url.toString().startsWith('https://')) {
|
const urlStr = item.url.toString()
|
||||||
|
|
||||||
|
if (urlStr.startsWith('data:')) {
|
||||||
|
const buffer = Buffer.from(urlStr.split(',')[1], 'base64')
|
||||||
|
return { stream: toReadable(buffer), type: 'buffer' } as const
|
||||||
|
}
|
||||||
|
|
||||||
|
if (urlStr.startsWith('http://') || urlStr.startsWith('https://')) {
|
||||||
return { stream: await getHttpStream(item.url, opts), type: 'remote' } as const
|
return { stream: await getHttpStream(item.url, opts), type: 'remote' } as const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user