Skip to content

weixin-ts / cdn/src / downloadMedia

Function: downloadMedia()

downloadMedia(options): Promise<Uint8Array<ArrayBufferLike>>

Defined in: cdn/src/download.ts:40

Download and decrypt a media file from the WeChat CDN.

Parameters

options

DownloadMediaOptions

Download configuration

Returns

Promise<Uint8Array<ArrayBufferLike>>

Decrypted file content as Uint8Array

Example

ts
import { downloadMedia } from '@weixin-ts/cdn'

// From an incoming message's image_item.media
const imageData = await downloadMedia({
  media: message.item_list[0].image_item.media,
  aesKeyHex: message.item_list[0].image_item.aeskey,
})

Released under the MIT License.