Parse Content-Disposition header
npm install content-disposition-parseContent-Disposition header based on this [content-disposition][git-url]
sh
$ npm install content-disposition-parse
`
$3
`js
const { ContentDisposition } = require('content-disposition-parse');
const result = ContentDisposition.parse('attachment; filename="example.txt"');
console.log(result);
//output result
{ type: 'attachment', parameters: { filename: 'example.txt' } }
`
$3
Specifies the disposition type, defaults to "attachment". This can also be
"inline", or any other value (all values except inline are treated like
attachment, but can convey additional information if both parties agree to
it). The type is normalized to lower-case.
Parse a Content-Disposition header string. This automatically handles extended
("Unicode") parameters by decoding them and providing them under the standard
parameter name. This will return an object with the following properties (examples
are shown for the string 'attachment; filename="EURO rates.txt"; filename*=UTF-8\'\'%e2%82%ac%20rates.txt'):
- type: The disposition type (always lower case). Example: 'attachment'
- parameters: An object of the parameters in the disposition (name of parameter
always lower case and extended versions replace non-extended versions). Example:
{filename: "€ rates.txt"}`