1.2.3 • Published 2 years ago

@obsidize/rotating-file-stream v1.2.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@obsidize/rotating-file-stream

Simple wrapper for streaming data to files on mobile devices in hybrid apps.

If you're using this for log capture on a cordova / capacitor app, consider using cordova-plugin-secure-logger instead.

If you need a pure NodeJS implementation, use rotating-file-stream instead.

Installation

  • npm:
npm install --save @obsidize/rotating-file-stream

API

Source documentation can be found here

Usage

  1. Create A RotationFileStream instance:
import { RotatingFileStream, CordovaFileEntryApi, CapacitorFileEntryApi } from '@obsidize/rotating-file-stream';

const fileStream = new RotatingFileStream({
	maxFileSize: 2e6, // 2MB
	files: CordovaFileEntryApi.createCacheRotationFiles(
		cdvFile, // @awesome-cordova-plugins/file reference
		'logs',
		['debug-a.log', 'debug-b.log']
	)
});

// Or if you want to use @capacitor/filesystem
const fileStream = new RotatingFileStream({
	maxFileSize: 2e6, // 2MB
	files: CapacitorFileEntryApi.createCacheRotationFiles(
		Filesystem, // @capacitor/filesystem reference
		'logs',
		['debug-a.log', 'debug-b.log']
	)
});
  1. Write to the stream:
const buffer = new ArrayBuffer(42);
fileStream.write(buffer).then(...);
  1. Read data back later on:
const entries = await fileStream.refreshAllEntries();

for (const entry of entries) {
	// read the entry data, or get its URL and do something with it
}
1.2.3

2 years ago

1.2.0

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.1.0

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago