Media addMedia method

This commit is contained in:
Dolan
2018-01-09 21:57:10 +00:00
parent 2adde9830c
commit a3945bc7f1

View File

@ -19,13 +19,17 @@ export class Media {
return data; return data;
} }
public addMedia(key: string, filePath: string): void { public addMedia(filePath: string): IMediaData {
this.map.set(key, { const key = path.basename(filePath);
const imageData = {
referenceId: this.map.values.length, referenceId: this.map.values.length,
stream: fs.createReadStream(filePath), stream: fs.createReadStream(filePath),
path: filePath, path: filePath,
fileName: path.basename(filePath), fileName: key,
}); };
this.map.set(key, imageData);
return imageData;
} }
public get array(): IMediaData[] { public get array(): IMediaData[] {