feathers-blob
Advanced tools
Comparing version 1.2.0 to 1.3.0
# Change Log | ||
## [v1.2.0](https://github.com/feathersjs/feathers-blob/tree/v1.2.0) (2016-08-18) | ||
[Full Changelog](https://github.com/feathersjs/feathers-blob/compare/v1.1.0...v1.2.0) | ||
**Closed issues:** | ||
- Unable to set ACL permissions for S3 [\#7](https://github.com/feathersjs/feathers-blob/issues/7) | ||
- unsupported mime types [\#6](https://github.com/feathersjs/feathers-blob/issues/6) | ||
**Merged pull requests:** | ||
- Add S3 Params when uploading files. [\#8](https://github.com/feathersjs/feathers-blob/pull/8) ([silvestreh](https://github.com/silvestreh)) | ||
## [v1.1.0](https://github.com/feathersjs/feathers-blob/tree/v1.1.0) (2016-06-17) | ||
@@ -4,0 +16,0 @@ [Full Changelog](https://github.com/feathersjs/feathers-blob/compare/v1.0.5...v1.1.0) |
import AWS from 'aws-sdk'; | ||
import Store from 's3-blob-store' | ||
import Store from 's3-blob-store'; | ||
import feathers from 'feathers'; | ||
@@ -10,3 +10,3 @@ import rest from 'feathers-rest'; | ||
accessKeyId: process.env.AWS_ACCESS_KEY_ID, | ||
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY, | ||
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY | ||
}); | ||
@@ -34,3 +34,3 @@ | ||
// A basic error handler, just like Express | ||
app.use(function(error, req, res, next){ | ||
app.use(function (error, req, res, next) { | ||
res.json(error); | ||
@@ -37,0 +37,0 @@ }); |
@@ -8,3 +8,3 @@ 'use strict'; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
//import errors from 'feathers-errors'; | ||
// import errors from 'feathers-errors'; | ||
@@ -61,47 +61,60 @@ | ||
key: 'get', | ||
value: function get(id, params, cb) { | ||
value: function get(id) { | ||
var _this = this; | ||
var ext = (0, _path.extname)(id); | ||
var contentType = _mimeTypes2.default.lookup(ext); | ||
this.Model.createReadStream({ | ||
key: id | ||
}).on('error', cb).pipe((0, _concatStream2.default)(function (buffer) { | ||
var _cb; | ||
return new Promise(function (resolve, reject) { | ||
_this.Model.createReadStream({ | ||
key: id | ||
}).on('error', reject).pipe((0, _concatStream2.default)(function (buffer) { | ||
var _resolve; | ||
var uri = (0, _dauria.getBase64DataURI)(buffer, contentType); | ||
var uri = (0, _dauria.getBase64DataURI)(buffer, contentType); | ||
cb(null, (_cb = {}, _defineProperty(_cb, this.id, id), _defineProperty(_cb, 'uri', uri), _defineProperty(_cb, 'size', buffer.length), _cb)); | ||
}.bind(this))); | ||
resolve((_resolve = {}, _defineProperty(_resolve, _this.id, id), _defineProperty(_resolve, 'uri', uri), _defineProperty(_resolve, 'size', buffer.length), _resolve)); | ||
})); | ||
}); | ||
} | ||
}, { | ||
key: 'create', | ||
value: function create(body, params, cb) { | ||
var id = body.id; | ||
var uri = body.uri; | ||
value: function create(body) { | ||
var _this2 = this; | ||
var _parseDataURI = (0, _dauria.parseDataURI)(uri); | ||
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var id = body.id, | ||
uri = body.uri; | ||
var buffer = _parseDataURI.buffer; | ||
var contentType = _parseDataURI.MIME; | ||
var _parseDataURI = (0, _dauria.parseDataURI)(uri), | ||
buffer = _parseDataURI.buffer, | ||
contentType = _parseDataURI.MIME; | ||
var hash = (0, _util.bufferToHash)(buffer); | ||
var ext = _mimeTypes2.default.extension(contentType); | ||
id = id || hash + '.' + ext; | ||
(0, _util.fromBuffer)(buffer).pipe(this.Model.createWriteStream({ | ||
key: id, | ||
params: params.s3 | ||
}, function () { | ||
var _cb2; | ||
return new Promise(function (resolve, reject) { | ||
(0, _util.fromBuffer)(buffer).pipe(_this2.Model.createWriteStream({ | ||
key: id, | ||
params: params.s3 | ||
}, function () { | ||
var _resolve2; | ||
cb(null, (_cb2 = {}, _defineProperty(_cb2, this.id, id), _defineProperty(_cb2, 'uri', uri), _defineProperty(_cb2, 'size', buffer.length), _cb2)); | ||
}.bind(this))).on('error', cb); | ||
return resolve((_resolve2 = {}, _defineProperty(_resolve2, _this2.id, id), _defineProperty(_resolve2, 'uri', uri), _defineProperty(_resolve2, 'size', buffer.length), _resolve2)); | ||
})).on('error', reject); | ||
}); | ||
} | ||
}, { | ||
key: 'remove', | ||
value: function remove(id, params, cb) { | ||
this.Model.remove({ | ||
key: id | ||
}, function (err) { | ||
cb(err, null); | ||
value: function remove(id) { | ||
var _this3 = this; | ||
return new Promise(function (resolve, reject) { | ||
_this3.Model.remove({ | ||
key: id | ||
}, function (error) { | ||
return error ? reject(error) : resolve(); | ||
}); | ||
}); | ||
@@ -108,0 +121,0 @@ } |
@@ -23,3 +23,3 @@ 'use strict'; | ||
function fromBuffer(buffer) { | ||
//assert.ok(Buffer.isBuffer(buffer)) | ||
// assert.ok(Buffer.isBuffer(buffer)) | ||
@@ -26,0 +26,0 @@ return (0, _from2.default)(function (size, next) { |
{ | ||
"name": "feathers-blob", | ||
"description": "Feathers blob service", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"homepage": "https://github.com/feathersjs/feathers-blob", | ||
@@ -33,3 +33,3 @@ "main": "lib/", | ||
"engines": { | ||
"node": ">= 0.12.0" | ||
"node": ">= 4" | ||
}, | ||
@@ -43,9 +43,18 @@ "scripts": { | ||
"release:major": "npm version major && npm publish", | ||
"compile": "rm -rf lib/ && babel -d lib/ src/", | ||
"compile": "rimraf lib/ && babel -d lib/ src/", | ||
"watch": "babel --watch -d lib/ src/", | ||
"jshint": "jshint src/. test/. --config", | ||
"mocha": "mocha test/ --compilers js:babel-core/register", | ||
"test": "npm run compile && npm run jshint && npm run mocha", | ||
"example": "babel-node examples/app" | ||
"lint": "eslint-if-supported semistandard --fix", | ||
"mocha": "mocha --opts mocha.opts", | ||
"test": "npm run compile && npm run lint && npm run coverage", | ||
"example": "babel-node examples/app", | ||
"coverage": "istanbul cover node_modules/mocha/bin/_mocha -- --opts mocha.opts" | ||
}, | ||
"semistandard": { | ||
"env": [ | ||
"mocha" | ||
], | ||
"ignore": [ | ||
"/lib" | ||
] | ||
}, | ||
"directories": { | ||
@@ -56,3 +65,3 @@ "lib": "lib" | ||
"concat-stream": "^1.5.1", | ||
"dauria": "^1.1.3", | ||
"dauria": "^2.0.0", | ||
"debug": "^2.2.0", | ||
@@ -68,13 +77,15 @@ "from2": "^2.1.1", | ||
"babel-core": "^6.5.2", | ||
"babel-plugin-add-module-exports": "^0.1.2", | ||
"babel-plugin-add-module-exports": "^0.2.1", | ||
"babel-preset-es2015": "^6.5.0", | ||
"body-parser": "^1.15.0", | ||
"eslint-if-supported": "^1.0.1", | ||
"feathers": "^2.0.0-pre.4", | ||
"feathers-rest": "^1.2.2", | ||
"fs-blob-store": "^5.2.1", | ||
"jshint": "^2.9.1", | ||
"mocha": "^2.4.5", | ||
"run-waterfall": "^1.1.3", | ||
"s3-blob-store": "^1.0.0" | ||
"istanbul": "^1.1.0-alpha.1", | ||
"mocha": "^3.2.0", | ||
"rimraf": "^2.5.4", | ||
"s3-blob-store": "^2.0.1", | ||
"semistandard": "^11.0.0" | ||
} | ||
} |
# feathers-blob | ||
[![Greenkeeper badge](https://badges.greenkeeper.io/feathersjs/feathers-blob.svg)](https://greenkeeper.io/) | ||
[![Build Status](https://travis-ci.org/feathersjs/feathers-blob.png?branch=master)](https://travis-ci.org/feathersjs/feathers-blob) | ||
[![Code Climate](https://codeclimate.com/github/feathersjs/feathers-blob.png)](https://codeclimate.com/github/feathersjs/feathers-blob) | ||
[![Test Coverage](https://codeclimate.com/github/feathersjs/feathers-blob/badges/coverage.svg)](https://codeclimate.com/github/feathersjs/feathers-blob/coverage) | ||
[![Dependency Status](https://img.shields.io/david/feathersjs/feathers-blob.svg?style=flat-square)](https://david-dm.org/feathersjs/feathers-blob) | ||
[![Download Status](https://img.shields.io/npm/dm/feathers-blob.svg?style=flat-square)](https://www.npmjs.com/package/feathers-blob) | ||
[![Slack Status](http://slack.feathersjs.com/badge.svg)](http://slack.feathersjs.com) | ||
@@ -70,3 +77,3 @@ > [Feathers](http://feathersjs.com) [`abstract blob store`](https://github.com/maxogden/abstract-blob-store) service | ||
const blobService = service({ | ||
const blobService = BlobService({ | ||
Model: blobStore | ||
@@ -86,2 +93,12 @@ }); | ||
Should you need to change your bucket's [options](http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#putObject-property), such as permissions, pass a `params.s3` object using a before hook. | ||
```js | ||
app.service('upload').before({ | ||
create(hook) { | ||
hook.params.s3 = { ACL: 'public-read' }; // makes uploaded files public | ||
} | ||
}); | ||
``` | ||
For a more complete example, see [examples/app](./examples/app.js) which can be run with `npm run example`. | ||
@@ -88,0 +105,0 @@ |
Sorry, the diff of this file is not supported yet
130527
10
157
110
16
+ Addeddauria@2.0.0(transitive)
- Removeddauria@1.1.5(transitive)
Updateddauria@^2.0.0