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

23 lines
758 B
TypeScript
Raw Normal View History

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';
import { Channel } from '../data-types';
2021-11-22 02:47:29 +00:00
import CombinedGuild from '../guild-combined';
2021-10-30 17:26:41 +00:00
2021-11-21 18:29:42 +00:00
export default function createUploadOverlayFromPath(document: Document, guild: CombinedGuild, channel: Channel, resourcePath: string): HTMLElement {
let resourceName = path.basename(resourcePath);
let element = BaseElements.createUploadOverlay(document, {
2021-11-22 02:47:29 +00:00
guild: guild, 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
}