mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
feat: handle maxContentLength in downloading media
This commit is contained in:
@@ -320,6 +320,20 @@ export const encryptedStream = async(
|
|||||||
try {
|
try {
|
||||||
for await (const data of stream) {
|
for await (const data of stream) {
|
||||||
fileLength += data.length
|
fileLength += data.length
|
||||||
|
|
||||||
|
if(
|
||||||
|
type === 'remote'
|
||||||
|
&& opts?.maxContentLength
|
||||||
|
&& fileLength + data.length > opts.maxContentLength
|
||||||
|
) {
|
||||||
|
throw new Boom(
|
||||||
|
`content length exceeded when encrypting "${type}"`,
|
||||||
|
{
|
||||||
|
data: { media, type }
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
sha256Plain = sha256Plain.update(data)
|
sha256Plain = sha256Plain.update(data)
|
||||||
if(writeStream) {
|
if(writeStream) {
|
||||||
if(!writeStream.write(data)) {
|
if(!writeStream.write(data)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user