expressjs/multer

File type shows correct on the frontend but it changes to application/octet-stream on the backend

Open

#1 250 ouverte le 6 avr. 2024

Voir sur GitHub
 (1 commentaire) (0 réactions) (0 assignés)JavaScript (1 043 forks)batch import
help wantedquestion

Métriques du dépôt

Stars
 (11 136 stars)
Métriques de merge PR
 (Merge moyen 9j 11h) (7 PRs mergées en 30 j)

Description

I am uploading file from frontend to get URL but when I upload the file with multer, it automatically changes the file type on the backend.

I used word changes here because the file type shows correct on the frontend. For example: the file I am uploading is of type

{
path: "2023-12-14 13-19-55.mkv"
type: "video/x-matroska"
lastModified: 1702539348430
lastModifiedDate: Thu Dec 14 2023 13:20:48 GMT+0545 (Nepal Time) {}
name: "2023-12-14 13-19-55.mkv"
size: 17555107
}

But on the backend it shows:

{
  fieldname: 'imageData',
  originalname: '2023-12-14 13-19-55.mkv',      
  encoding: '7bit',
  mimetype: 'application/octet-stream',
  destination: 'uploads/',
  filename: '1712392840374-2023-12-14 13-19-55.mkv',
  path: 'uploads\\1712392840374-2023-12-14 13-19-55.mkv',
  size: 17555107
}

Why does it change the file type?

Guide contributeur