mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
feat: expose axios options
This commit is contained in:
@@ -376,6 +376,7 @@ const toSmallestChunkSize = (num: number) => {
|
||||
export type MediaDownloadOptions = {
|
||||
startByte?: number
|
||||
endByte?: number
|
||||
options?: AxiosRequestConfig<any>
|
||||
}
|
||||
|
||||
export const getUrlFromDirectPath = (directPath: string) => `https://${DEF_HOST}${directPath}`
|
||||
@@ -398,7 +399,7 @@ export const downloadContentFromMessage = (
|
||||
export const downloadEncryptedContent = async(
|
||||
downloadUrl: string,
|
||||
{ cipherKey, iv }: MediaDecryptionKeyInfo,
|
||||
{ startByte, endByte }: MediaDownloadOptions = { }
|
||||
{ startByte, endByte, options }: MediaDownloadOptions = { }
|
||||
) => {
|
||||
let bytesFetched = 0
|
||||
let startChunk = 0
|
||||
@@ -417,6 +418,7 @@ export const downloadEncryptedContent = async(
|
||||
const endChunk = endByte ? toSmallestChunkSize(endByte || 0) + AES_CHUNK_SIZE : undefined
|
||||
|
||||
const headers: { [_: string]: string } = {
|
||||
...options?.headers || { },
|
||||
Origin: DEFAULT_ORIGIN,
|
||||
}
|
||||
if(startChunk || endChunk) {
|
||||
@@ -430,6 +432,7 @@ export const downloadEncryptedContent = async(
|
||||
const fetched = await getHttpStream(
|
||||
downloadUrl,
|
||||
{
|
||||
...options || { },
|
||||
headers,
|
||||
maxBodyLength: Infinity,
|
||||
maxContentLength: Infinity,
|
||||
@@ -514,7 +517,10 @@ export function extensionForMediaMessage(message: WAMessageContent) {
|
||||
return extension
|
||||
}
|
||||
|
||||
export const getWAUploadToServer = ({ customUploadHosts, fetchAgent, logger }: SocketConfig, refreshMediaConn: (force: boolean) => Promise<MediaConnInfo>): WAMediaUploadFunction => {
|
||||
export const getWAUploadToServer = (
|
||||
{ customUploadHosts, fetchAgent, logger, options }: SocketConfig,
|
||||
refreshMediaConn: (force: boolean) => Promise<MediaConnInfo>,
|
||||
): WAMediaUploadFunction => {
|
||||
return async(stream, { mediaType, fileEncSha256B64, timeoutMs }) => {
|
||||
const { default: axios } = await import('axios')
|
||||
// send a query JSON to obtain the url & auth token to upload our media
|
||||
@@ -546,7 +552,9 @@ export const getWAUploadToServer = ({ customUploadHosts, fetchAgent, logger }: S
|
||||
url,
|
||||
reqBody,
|
||||
{
|
||||
...options,
|
||||
headers: {
|
||||
...options.headers || { },
|
||||
'Content-Type': 'application/octet-stream',
|
||||
'Origin': DEFAULT_ORIGIN
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user