How to use the @plumier/core.errorMessage.FileSizeExceeded function in @plumier/core

To help you get started, we’ve selected a few @plumier/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github plumier / plumier / packages / multipart / src / index.ts View on Github external
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;
    }
}