cordis/client/webapp/elements/overlay-upload-path.ts

23 lines
770 B
TypeScript

import * as fs from 'fs/promises';
import * as path from 'path';
import BaseElements from './require/base-elements';
import { Channel } from '../data-types';
import ClientController from '../client-controller';
export default function createUploadOverlayFromPath(document: Document, server: ClientController, channel: Channel, resourcePath: string): HTMLElement {
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;
}