UNPKG

@astro-utils/forms

Version:

Server component for Astro (call server functions from client side with validation and state management)

23 lines (22 loc) 584 B
import { createReadStream } from "fs"; import { stat, copyFile } from "fs/promises"; export class BigFile { constructor(name, path, size) { this.name = name; this.path = path; this.size = size; } stream(options) { return createReadStream(this.path, options); } copyTo(destination) { return copyFile(this.path, destination); } static async loadFileSize(path) { const file = await stat(path); if (!file.isFile()) { throw new Error('Not a file'); } return file.size; } }