Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multer doesn't save an extensionand name of file #21

Open
megabatz opened this issue Feb 21, 2018 · 1 comment
Open

Multer doesn't save an extensionand name of file #21

megabatz opened this issue Feb 21, 2018 · 1 comment

Comments

@megabatz
Copy link

From client:
const xhr = new XMLHttpRequest;
xhr.open('POST', '/some/url', true);
xhr.send(new FormData(form));

On server:
import Router from 'koa-router';
import path from 'path';
import multer from 'koa-multer';
const upload = multer({dest: path.join(__dirname, 'pdf')});
const router = new Router();
router.post('some/url', upload.single('file'), controller)

When multer is saving, it gener for file random name without extension.

@sebastialonso
Copy link

I'm having the issue. But, for the moment, I'm taken the originalname name. You can take the mimetype field to get the file's content type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants