Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/binded/tus-metadata
Encode and decode Tus.io Upload-Metatada strings
https://github.com/binded/tus-metadata
Last synced: about 5 hours ago
JSON representation
Encode and decode Tus.io Upload-Metatada strings
- Host: GitHub
- URL: https://github.com/binded/tus-metadata
- Owner: binded
- License: mit
- Created: 2016-09-16T17:56:26.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2016-09-18T21:50:12.000Z (about 8 years ago)
- Last Synced: 2024-06-20T22:31:34.184Z (5 months ago)
- Language: JavaScript
- Homepage:
- Size: 9.77 KB
- Stars: 1
- Watchers: 9
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tus-metadata
[![Build Status](https://travis-ci.org/blockai/tus-metadata.svg?branch=master)](https://travis-ci.org/blockai/tus-metadata)
Encode and decode Tus [Upload-Metatada](http://tus.io/protocols/resumable-upload.html#upload-metadata).
## Install
```bash
npm install --save tus-metadata
```Requires Node v6+
## Usage
See [./test](./test) directory for usage examples.
**decode(str)**
Accepts an `Upload-Metadata` encoded string and returns a key/value object.
**encode(obj)**
Accepts an object and returns an `Upload-Metadata` encoded string.
```javascript
import { encode, decode } from 'tus-metadata'const str = 'filename d29ybGRfZG9taW5hdGlvbl9wbGFuLnBkZg==,mimetype dGV4dC9wbGFpbgo='
decode(str)
// => {filename: 'world_domination_plan.pdf', mimetype: 'text/plain'}encode(decode(str))
// => filename d29ybGRfZG9taW5hdGlvbl9wbGFuLnBkZg==,mimetype dGV4dC9wbGFpbgo=
```