fix: Handle data: URIs in getStream to prevent server crash (#1524)

This commit is contained in:
João Lucas de Oliveira Lopes
2025-07-04 19:25:19 -03:00
committed by GitHub
parent 4ccec1f6ce
commit 92b4c68de0

View File

@@ -317,7 +317,14 @@ export const getStream = async (item: WAMediaUpload, opts?: AxiosRequestConfig)
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
}