File size: 510 Bytes
a99b4ac
 
 
 
 
66f11df
a99b4ac
66f11df
a99b4ac
cab8fdd
 
 
 
 
 
a99b4ac
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import path from 'node:path'
import fs from 'node:fs'

import tmpDir from 'temp-dir'

export const keepVideo = async (fileName: string, targetDirPath: string): Promise<string> => {
  const sourceFilePath = path.join(tmpDir, fileName)
  const targetFilePath = path.join(targetDirPath, fileName)

  await fs.promises.copyFile(sourceFilePath, targetFilePath)
  try {
    await fs.promises.unlink(sourceFilePath)
  } catch (err) {
    console.log('failed to cleanup (no big deal..)')
  }

  return targetFilePath
}