Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async save(subDirectory?: string): Promise {
const result: FileUploadInfo[] = []
const temps = await asyncBusboy(this.context, this.option)
const invalid = temps.filter(x => !x.validSize)
if (invalid.length > 0)
throw new HttpStatusError(422, errorMessage.FileSizeExceeded.format(invalid.map(x => x.originalName).join(",")))
for (const temp of temps) {
const baseName = basename(temp.fileName)
const dir = join(this.option.uploadPath, subDirectory || "")
const destFile = join(dir, baseName)
await checkDirectory(dir)
await copy(temp.fileName, destFile)
const { validSize, fileName, ...info } = temp;
result.push({ ...info, fileName: join(subDirectory || "", baseName) })
}
return result;
}
}