Upload Data

The Assets provider allows you to upload in-memory data buffers directly, without writing to a temporary file first. This is useful when you have data already in memory, such as generated reports or processed binary content.

Method signature

uploadData(data: Buffer[], remoteDir: string, filenames?: string[], retention?: FILE_RETENTION_PERIOD): Promise<void>

Uploading Data Buffers

import { vcr, Assets, FILE_RETENTION_PERIOD } from '@vonage/vcr-sdk';

const session = vcr.createSession();
const assets = new Assets(session);

const reportData = Buffer.from(JSON.stringify({ key: 'value' }));

await assets.uploadData(
  [reportData],
  '/data/',
  ['report.json'],
  FILE_RETENTION_PERIOD.THREE_MONTHS,
);

The filenames parameter is optional. If omitted, the platform assigns filenames automatically. The retention parameter is also optional; see File Retention Periods for available values.