Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kvnneff/township-media
A Township plugin that adds routes and methods for managing media uploads
https://github.com/kvnneff/township-media
Last synced: 3 months ago
JSON representation
A Township plugin that adds routes and methods for managing media uploads
- Host: GitHub
- URL: https://github.com/kvnneff/township-media
- Owner: kvnneff
- License: mit
- Created: 2015-06-29T23:25:40.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-08-31T18:13:34.000Z (over 9 years ago)
- Last Synced: 2024-10-03T06:52:29.419Z (4 months ago)
- Language: JavaScript
- Size: 293 KB
- Stars: 5
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-starred - kvnneff/township-media - A Township plugin that adds routes and methods for managing media uploads (others)
README
# township-media
[![alt text](https://travis-ci.org/kvnneff/township-media.svg)](https://travis-ci.org/kvnneff/township-media)A [Township](https://github.com/civicmakerlab/township) plugin that adds routes and methods for managing media uploads. Includes support for Amazon S3.
## Example
``` js
var township = require('township')
var media = require('township-media')
var memdown = require('memdown')
var levelup = require('levelup')
var db = levelup('db', {db: memdown})var options = {
uploadDir: __dirname + '/uploads',
allowedMimeTypes: ['png', 'jpeg', 'gif', 'mpeg', 'avi', 'ogg']
maxFileSize: 4000000
}var server = township(db)
server.add(media(options))
server.listen()
```## Options
* `maxFileSize` - The maximum allowed file size (in bytes). The default is `2000000` (2mb)
* `allowedMimeTypes` - The allowed mime types for uploaded files. [mime-types](https://github.com/jshttp/mime-types) is used to verify mime types so the following is all valid: `['json', 'markdown', '.png', 'jpeg']`. Defaults to allowing all mime types.
* `uploadDir` - The path to prepend to the files being saved. When using disk storage this will look like `/assets/[uploadDir]/image.jpg`. When using S3 this will look like `https://s3.amazonaws.com/[bucket]/[uploadDir]/image.jpg`. The default is `uploads`.Required when using AWS S3:
* `accessKeyId` - Your AWS S3 access key id.
* `secretAccessKey` - Your AWS S3 secret access key.
* `bucket` - Your AWS S3 bucket name.## License
MIT