import * as fs from 'fs/promises'; import * as path from 'path'; import { Channel } from '../data-types'; import ClientController from '../client-controller'; import BaseElements from './require/base-elements'; import IState from './require/elements-state'; import { $, $$, $$$, $$$$ } from './require/q-module'; export default function createUploadOverlayFromPath(state: IState, server: ClientController, channel: Channel, resourcePath: string): HTMLElement { const { document } = state; $.setDocument(document); let resourceName = path.basename(resourcePath); let element = BaseElements.createUploadOverlay(document, { server: server, channel: channel, resourceName: resourceName, resourceBuffFunc: async () => { return await fs.readFile(resourcePath); }, resourceSizeFunc: async () => { let stat = await fs.stat(resourcePath); return stat.size; } }); return element; }