question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BUG?????? Headers Never Applied

See original GitHub issue

I am using FormData and multipart/form-data to upload media files (i.e. video/mp4 and text/vtt).

I’ve tried numerous times to use base64 as my transfer encoding and apply Content Type (i.e. mimetype) of text/vtt for my sample.vtt file; however, multer continues to give me application/octet-stream.

Where are my headers ever applied?

https://github.com/expressjs/multer/blob/f181839e8de0308275eccc49f35ffd18b7c1dc15/lib/read-body.js#L96

I’ve looked through Busboy, Dicer, and Multer. I can’t seem to find the use-case of the headers I’ve been sending.

Multer make-middleware line 33 busboy = new Busboy({ headers: req.headers, limits: limits, preservePath: preservePath })

Busboy main.js line 71 this._parser = type(this, cfg); where cfg contains our headers from multer

Busboy multipart.js line 24 function Multipart(boy, cfg) { follow cfg and you will never find headers used?

Busboy multipart.js line 124 part.on('header', function(header) { if headers are never passed to Dicer in line 98 (same file), then how will header ever have any of the values I’ve sent in my request?

Perhaps I’m having tunnel vision and can’t see what’s going on.

Can someone help?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
jonchurchcommented, Mar 24, 2020

I’m not able to reproduce this behavior with code I’ve written myself. Can you provide a minimal reproducible example that shows the behavior?

In the simple upload test app I use to reproduce issues where I make a multipart upload from an html form, I’m sending a .vtt file as a single upload and multer is properly detecting the clientReportedMimeType as text/vtt.

I put my repro attempt into this codesandbox which points to this branch of my repo with the code.

I’m hoping to nail down if it’s an issue with how you’re making your request, or with Multer itself. Often there’s an issue with how someone is making their request, but since we’re working with the new version of Multer here, your feedback is highly valuable in making sure we aren’t dealing with a bug here. Thanks!

0reactions
nooniicommented, Mar 24, 2020

Trying to upload a example.vtt file in multer 2.0

Accept: application/json, text/plain, */*
Accept-Encoding: gzip, deflate
Content-Length: 333
Content-Transfer-Encoding: base64
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary1ME0fBD7X0xjqj2q

Response

Notice the detectedMimeType: null and detectedFileExtension: '' are not found. The clientReportedMimeType is application/octet-stream.

Multer doesn’t seem to like caption/subtitle media files.

{
    fieldName: 'caption',
    originalName: 'sample.vtt',
    clientReportedMimeType: 'application/octet-stream',
    clientReportedFileExtension: '.vtt',
    path: 'C:\\Users\\User\\AppData\\Local\\Temp\\W2CC1VG',
    size: 132,
    detectedMimeType: null,
    detectedFileExtension: '',
    stream: ReadStream {
      _readableState: [ReadableState],
      readable: true,
      _events: [Object: null prototype],
      _eventsCount: 2,
      _maxListeners: undefined,
      path: 'C:\\Users\\User\\AppData\\Local\\Temp\\W2CC1VG',
      fd: null,
      flags: 'r',
      mode: 438,
      start: undefined,
      end: Infinity,
      autoClose: true,
      pos: undefined,
      bytesRead: 0,
      closed: false,
      [Symbol(kCapture)]: false,
      [Symbol(kIsPerformingIO)]: false
    }
  }

Note: temp files hangs in my temp folder after successful or failed response until I restart app.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Empty or Missing Table Header - Equalize Digital
An empty table header error means that one of the table headers on your post or page does not contain any text. This...
Read more >
Prerendering does not have any distinguishing HTTP headers
The header solution won't work. When a prerender is swapped in, no additional HTTP requests are made. The invisible tab is just made...
Read more >
The headers we don't want - Fastly
The headers we don't want. HTTP headers are an important way of controlling how caches and browsers process your web content.
Read more >
python - Is it a bug to omit an Accept */* header in an HTTP/1.0 ...
Without the accept header, the returned content-type of application/json; charset=UTF-8 becomes text/javascript; charset=UTF-8 . That may be a bug in Facebook's ...
Read more >
7 Keys to the Mystery of a Missing Cookie - Medium
If this helped, you now know the issue and you can apply the fix. ... OPTIONS response headers instructs a browser how to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found