Fix base64 upload issues, bring in patched gridfs-stream

This commit is contained in:
John Lyon-Smith
2018-04-26 07:49:34 -07:00
parent 3ddb9ebc2d
commit 109e9f4d3d
4 changed files with 1131 additions and 1135 deletions

2259
server/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -31,7 +31,7 @@
"cors": "^2.8.3", "cors": "^2.8.3",
"credential": "^2.0.0", "credential": "^2.0.0",
"express": "^4.15.2", "express": "^4.15.2",
"gridfs-stream": "^1.1.1", "gridfs-stream": "jlyonsmith/gridfs-stream",
"handlebars": "^4.0.10", "handlebars": "^4.0.10",
"http-errors": "^1.6.1", "http-errors": "^1.6.1",
"json5": "^0.5.1", "json5": "^0.5.1",

View File

@@ -66,7 +66,6 @@ export class AssetRoutes {
async getAsset(req, res, next) { async getAsset(req, res, next) {
const assetId = req.params._id const assetId = req.params._id
const file = await this.db.gridfs.findOneAsync({ _id: assetId }) const file = await this.db.gridfs.findOneAsync({ _id: assetId })
if (!file) { if (!file) {

View File

@@ -6,8 +6,6 @@ import autobind from "autobind-decorator"
import * as Schemas from "./schemas" import * as Schemas from "./schemas"
import util from "util" import util from "util"
Grid.mongo = mongoose.mongo
@autobind @autobind
export class DB { export class DB {
constructor() { constructor() {
@@ -20,7 +18,7 @@ export class DB {
autoIndex: !isProduction, autoIndex: !isProduction,
}) })
this.gridfs = Grid(connection.db) this.gridfs = Grid(connection.db, mongoose.mongo)
this.gridfs.findOneAsync = util.promisify(this.gridfs.findOne) this.gridfs.findOneAsync = util.promisify(this.gridfs.findOne)
this.gridfs.removeAsync = util.promisify(this.gridfs.remove) this.gridfs.removeAsync = util.promisify(this.gridfs.remove)