2021-10-30 17:26:41 +00:00
|
|
|
import * as fs from 'fs/promises';
|
|
|
|
import * as path from 'path';
|
|
|
|
|
|
|
|
import BaseElements from './require/base-elements';
|
|
|
|
|
2021-11-07 16:50:30 +00:00
|
|
|
import { Channel } from '../data-types';
|
|
|
|
import ClientController from '../client-controller';
|
2021-10-30 17:26:41 +00:00
|
|
|
|
2021-11-07 16:50:30 +00:00
|
|
|
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;
|
2021-10-30 17:26:41 +00:00
|
|
|
}
|