fix: download on axios

This commit is contained in:
Adhiraj Singh
2021-12-19 22:25:17 +05:30
parent 072706368c
commit db941f1472

View File

@@ -325,18 +325,17 @@ export const downloadContentFromMessage = async(
} }
} }
const endChunk = endByte ? toSmallestChunkSize(endByte || 0)+AES_CHUNK_SIZE : undefined const endChunk = endByte ? toSmallestChunkSize(endByte || 0)+AES_CHUNK_SIZE : undefined
let rangeHeader: string | undefined = undefined
if(startChunk || endChunk) { const headers: { [_: string]: string } = {
rangeHeader = `bytes=${startChunk}-` Origin: DEFAULT_ORIGIN,
if(endChunk) rangeHeader += endChunk
} }
if(startChunk || endChunk) {
headers.Range = `bytes=${startChunk}-`
if(endChunk) headers.Range += endChunk
}
// download the message // download the message
const fetched = await getHttpStream(downloadUrl, { const fetched = await getHttpStream(downloadUrl, { headers })
headers: {
Origin: DEFAULT_ORIGIN,
Range: rangeHeader
}
})
let remainingBytes = Buffer.from([]) let remainingBytes = Buffer.from([])
const { cipherKey, iv } = getMediaKeys(mediaKey, type) const { cipherKey, iv } = getMediaKeys(mediaKey, type)