From a0b012d36425a950b65c1d70fd38d6e6685f8d38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaros=C5=82aw=20Wasiak?= Date: Tue, 11 Oct 2022 14:13:08 +0000 Subject: [PATCH] fix: fixed wrong file property name --- src/import.handler.ts | 6 +++--- src/utils.ts | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/import.handler.ts b/src/import.handler.ts index f5134cf..d8aec4d 100644 --- a/src/import.handler.ts +++ b/src/import.handler.ts @@ -1,7 +1,7 @@ -import { getFileFromRequest, getImporterByFileName } from './utils'; import { ActionHandler, ActionResponse } from 'adminjs'; -import util from 'util'; import fs from 'fs'; +import util from 'util'; +import { getFileFromRequest, getImporterByFileName } from './utils'; const readFile = util.promisify(fs.readFile); @@ -13,7 +13,7 @@ export const importHandler: ActionHandler = async ( const file = getFileFromRequest(request); const importer = getImporterByFileName(file.name); - const fileContent = await readFile(file.name); + const fileContent = await readFile(file.path); await importer(fileContent.toString(), context.resource); return {}; diff --git a/src/utils.ts b/src/utils.ts index d9efc20..7c204e7 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -8,10 +8,10 @@ import { Filter, ValidationError, } from 'adminjs'; -import { Importer } from './parsers'; -import { jsonImporter } from './modules/json/json.importer'; import { csvImporter } from './modules/csv/csv.importer'; +import { jsonImporter } from './modules/json/json.importer'; import { xmlImporter } from './modules/xml/xml.importer'; +import { Importer } from './parsers'; export const saveRecords = async ( records: Record[], @@ -52,7 +52,7 @@ export const postActionHandler = ( return handler(request, response, context); }; -export const getFileFromRequest = (request: ActionRequest): File => { +export const getFileFromRequest = (request: ActionRequest) => { const file = request.payload?.file; if (!file?.path) {