Skip to content

Commit

Permalink
fix: fixed wrong file property name
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarosław Wasiak authored and dziraf committed Oct 13, 2022
1 parent 55836ec commit 3ea019f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/import.handler.ts
Original file line number Diff line number Diff line change
@@ -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);

Expand All @@ -13,7 +13,7 @@ export const importHandler: ActionHandler<ActionResponse> = 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 {};
Expand Down
6 changes: 3 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, any>[],
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 3ea019f

Please sign in to comment.