diff options
author | Sam Wilkins <samwilkins333@gmail.com> | 2020-02-17 14:54:30 -0500 |
---|---|---|
committer | Sam Wilkins <samwilkins333@gmail.com> | 2020-02-17 14:54:30 -0500 |
commit | f7fae0325a0adb64797bff2bcaffc2890ab198d7 (patch) | |
tree | adb2cd2ecbc01ba22d2894663edb3a8440d07b36 /src | |
parent | ba9351bc009b6f78ca9815b481bc5643f8af96e0 (diff) |
fixed pdf upload naming issues
Diffstat (limited to 'src')
-rw-r--r-- | src/server/DashUploadUtils.ts | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/server/DashUploadUtils.ts b/src/server/DashUploadUtils.ts index 8f31f990f..ea4c26ca2 100644 --- a/src/server/DashUploadUtils.ts +++ b/src/server/DashUploadUtils.ts @@ -83,10 +83,11 @@ export namespace DashUploadUtils { } async function UploadPdf(file: File) { - const { path, name } = file; - const dataBuffer = readFileSync(path); + const { path: sourcePath } = file; + const dataBuffer = readFileSync(sourcePath); const result: ParsedPDF = await parse(dataBuffer); await new Promise<void>((resolve, reject) => { + const name = path.basename(sourcePath); const textFilename = `${name.substring(0, name.length - 4)}.txt`; const writeStream = createWriteStream(serverPathToFile(Directory.text, textFilename)); writeStream.write(result.text, error => error ? reject(error) : resolve()); @@ -183,7 +184,8 @@ export namespace DashUploadUtils { }; export async function MoveParsedFile(file: File, destination: Directory): Promise<Upload.FileResponse> { - const { name, path: sourcePath } = file; + const { path: sourcePath } = file; + const name = path.basename(sourcePath); return new Promise(resolve => { const destinationPath = serverPathToFile(destination, name); rename(sourcePath, destinationPath, error => { |