Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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=
```