40 lines
1.0 KiB
TypeScript
40 lines
1.0 KiB
TypeScript
import * as fs from 'fs';
|
|
|
|
export function MoveFilePathHelper() {}
|
|
|
|
// export class MoveFileToDirIdHelper {
|
|
// public srcDir: string;
|
|
// public fileName: string;
|
|
|
|
// constructor(private file_url: string = null) {}
|
|
|
|
// execute(): string {
|
|
// try {
|
|
// this.getSrcDir();
|
|
// this.getFileName();
|
|
|
|
// const copyFile = `${this.fileName}-copy`;
|
|
// fs.mkdirSync(`./uploads/${this.srcDir}`, { recursive: true });
|
|
// fs.copyFileSync(
|
|
// this.file_url,
|
|
// `./uploads/${this.srcDir}/${this.fileName}`,
|
|
// );
|
|
// fs.unlinkSync(`${this.file_url}`);
|
|
|
|
// this.file_url = `uploads/${this.srcDir}/${this.fileName}`;
|
|
// } catch (error) {
|
|
// console.error('Error moving file:', error);
|
|
// }
|
|
|
|
// return this.file_url;
|
|
// }
|
|
|
|
// private getSrcDir(): void {
|
|
// this.srcDir = this.file_url.split('/').slice(2, -1).join('/');
|
|
// }
|
|
|
|
// private getFileName(): void {
|
|
// this.fileName = this.file_url.split('/').slice(-1).join('/');
|
|
// }
|
|
// }
|