SoftwareBrothers / adminjs-import-export

MIT License
5 stars 25 forks source link

Error on .csv import: ENOENT: no such file or directory, open 'filename.csv' #8

Open ardnaskela opened 2 years ago

ardnaskela commented 2 years ago

Describe the bug When importing a .csv file into a table, it fails with error 500, log message: Error on .csv import: ENOENT: no such file or directory, open 'filename.csv'. Export is working file. Tried on Windows 10 and Zorin OS 16.1 Lite.

Installed libraries and their versions "@adminjs/express": "^5.0.0", "@adminjs/import-export": "^2.0.0", "@adminjs/nestjs": "^5.0.0", "@adminjs/prisma": "^3.0.1"

To Reproduce Follow the steps to create a basic NestJS/Prisma project: https://docs.nestjs.com/recipes/prisma Install AdminJs and its dependencies for NestJS: https://docs.adminjs.co/module-@adminjs_nestjs.html Install AdminJs and its dependencies for Prisma: https://docs.adminjs.co/module-@adminjs_prisma.html Install AdminJs import-export: https://www.npmjs.com/package/@adminjs/import-export

Create the following AdminJs resource: { resource: { model: dmmf.modelMap.Post, client: prisma }, features: [importExportFeature()], }

Create a simple import.csv file and place it under /home/username/Documents on an Ubuntu-based Linux or under Documents on Windows 10: title,content,published,author Test Title,Test Content,true,

Launch AdminJs dashboard, Posts section and try to import the file. It gives the following error: Error: ENOENT: no such file or directory, open 'filename.csv'

ardnaskela commented 2 years ago

Hello, from the looks of it, the bug should be fixed by the latest pull request ("update deps && fix pathname") that substitutes "await readFile(file.name)" with "await readFile(file.path)" in import.handler.ts so feel free to close the issue once it gets released.

Thanks.