From 5a2d1fab4386ec193323d8798e9d8cd27c847ebe Mon Sep 17 00:00:00 2001 From: Arthur DANJOU Date: Tue, 24 Aug 2021 21:10:24 +0200 Subject: [PATCH] Add file overwriting --- app/Controllers/Http/FilesController.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/Controllers/Http/FilesController.ts b/app/Controllers/Http/FilesController.ts index 2bb89a1..e9de178 100755 --- a/app/Controllers/Http/FilesController.ts +++ b/app/Controllers/Http/FilesController.ts @@ -24,11 +24,14 @@ export default class FilesController { } await file.move(Application.makePath('storage'), { - name: `${label}.${file.extname}` + name: `${label}.${file.extname}`, + overwrite: true }) return response.status(200).send({ - file: await File.create({ + file: await File.firstOrCreate({ + label: label + }, { fileName: `${label}.${file.extname}`, label: label })