function parseSnapshotSize
parseSnapshotSize(xml: string): number

Reads the announced image size from the reply to a snapshot request.

Examples

Read the size

import { assertEquals } from "@std/assert";
import { parseSnapshotSize } from "@hertzg/reolink-api/protocol/snapshot";

assertEquals(
  parseSnapshotSize("<body><Snap><pictureSize>1024</pictureSize></Snap></body>"),
  1024,
);

Parameters

xml: string

The decrypted reply body.

Return Type

number

The image size in bytes.

Throws

Error

When the reply has no <pictureSize> element.

Usage

import { parseSnapshotSize } from "protocol/snapshot.ts";