Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/binded/tus-header-parser
Express middleware that parses Tus headers and sets them inside a Map on req.tus
https://github.com/binded/tus-header-parser
Last synced: about 4 hours ago
JSON representation
Express middleware that parses Tus headers and sets them inside a Map on req.tus
- Host: GitHub
- URL: https://github.com/binded/tus-header-parser
- Owner: binded
- License: mit
- Created: 2016-09-16T22:54:35.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2016-09-17T04:01:36.000Z (about 8 years ago)
- Last Synced: 2024-11-01T05:17:09.768Z (16 days ago)
- Language: JavaScript
- Homepage:
- Size: 10.7 KB
- Stars: 1
- Watchers: 9
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tus-header-parser
[![Build Status](https://travis-ci.org/blockai/tus-header-parser.svg?branch=master)](https://travis-ci.org/blockai/tus-header-parser)
Express middleware that parses [Tus
headers](http://tus.io/protocols/resumable-upload.html#headers) and sets
them on `req.tus`.- Ignores syntactically invalid headers
- Object keys are header names which have been converted to camelCase**Parsed headers:**
Tus-Resumable, Upload-Offset, Upload-Length, Upload-Metadata,
Upload-Defer-Length, Upload-Checksum, Upload-Concat## Install
```bash
npm install --save tus-header-parser
```Requires Node v6+
## Usage
See [./test](./test) directory for usage examples.
```javascript
import tusParser from 'tus-header-parser'
// ...
app.use(tusParser())
app.use((req, res, next) => {
console.log(req.headers)
// {
// 'tus-resumable': '1.0.0',
// 'upload-offset': '1000',
// 'upload-defer-length': '1',
// 'upload-length': '1337',
// 'upload-metadata': 'filename d29ybGRfZG9taW5hdGlvbl9wbGFuLnBkZg==,foo YmFy',
// 'upload-checksum': 'sha Kq5sNclPz7QV2+lfQIuc6R7oRu0=',
// 'upload-concat': 'final;/files/a /files/b',
// }
console.log(req.tus)
// {
// tusResumable: '1.0.0',
// uploadOffset: 1000,
// uploadDeferLength: 1,
// uploadLength: 1337,
// uploadMetadata: {
// filename: 'world_domination_plan.pdf',
// foo: 'bar',
// },
// uploadChecksum: {
// algorithm: 'sha',
// checksum: ,
// },
// uploadConcat: {
// final: true,
// urls: ['/files/a', '/files/b'],
// },
// }
})
```