Change docx folder to more appropriate "file" folder

This commit is contained in:
Dolan
2017-12-20 01:03:20 +00:00
parent 43ebfe7a2f
commit 2358139a6b
117 changed files with 22 additions and 23 deletions

40
src/file/media/media.ts Normal file
View File

@ -0,0 +1,40 @@
import * as fs from "fs";
import * as path from "path";
import { IData } from "./data";
export class Media {
private map: Map<string, IData>;
constructor() {
this.map = new Map<string, IData>();
}
public getMedia(key: string): IData {
const data = this.map.get(key);
if (data === undefined) {
throw new Error(`Cannot find image with the key ${key}`);
}
return data;
}
public addMedia(key: string, filePath: string): void {
this.map.set(key, {
referenceId: this.map.values.length,
stream: fs.createReadStream(filePath),
path: filePath,
fileName: path.basename(filePath),
});
}
public get array(): IData[] {
const array = new Array<IData>();
this.map.forEach((data) => {
array.push(data);
});
return array;
}
}