Fix admin/user login issues
This commit is contained in:
@@ -8,22 +8,7 @@ import config from "config"
|
||||
import autobind from "autobind-decorator"
|
||||
import { PassThrough } from "stream"
|
||||
import { catchAll } from "."
|
||||
|
||||
function pipeToGridFS(readable, writeable) {
|
||||
const promise = new Promise((resolve, reject) => {
|
||||
readable.on("error", (error) => {
|
||||
reject(error)
|
||||
})
|
||||
writeable.on("error", (error) => {
|
||||
reject(error)
|
||||
})
|
||||
writeable.on("finish", (file) => {
|
||||
resolve(file)
|
||||
})
|
||||
})
|
||||
readable.pipe(writeable)
|
||||
return promise
|
||||
}
|
||||
import { pipeToPromise } from "../../util"
|
||||
|
||||
@autobind
|
||||
export class AssetRoutes {
|
||||
@@ -109,7 +94,7 @@ export class AssetRoutes {
|
||||
}
|
||||
|
||||
async beginAssetUpload(req, res, next) {
|
||||
const uploadId = this.db.newObjectId()
|
||||
const uploadId = this.db.newObjectId().toString()
|
||||
let {
|
||||
fileName,
|
||||
uploadSize,
|
||||
@@ -224,12 +209,12 @@ export class AssetRoutes {
|
||||
if (uploadedChunks >= uploadData.numberOfChunks) {
|
||||
let readable = redisReadStream(this.rs.client, uploadDataId)
|
||||
let writeable = this.db.gridfs.openUploadStreamWithId(
|
||||
uploadId,
|
||||
this.db.newObjectId(uploadId),
|
||||
uploadData.fileName,
|
||||
{ contentType: uploadData.contentType }
|
||||
)
|
||||
|
||||
const file = await pipeToGridFS(readable, writeable)
|
||||
const file = await pipeToPromise(readable, writeable)
|
||||
|
||||
await Promise.all([
|
||||
this.rs.del(uploadId),
|
||||
|
||||
Reference in New Issue
Block a user