summaryrefslogtreecommitdiff
path: root/bucky
diff options
context:
space:
mode:
Diffstat (limited to 'bucky')
-rw-r--r--bucky/app/bucky.js7
-rw-r--r--bucky/app/router.js7
-rw-r--r--bucky/util/upload.js6
3 files changed, 14 insertions, 6 deletions
diff --git a/bucky/app/bucky.js b/bucky/app/bucky.js
index 2b07f03..49ad8e0 100644
--- a/bucky/app/bucky.js
+++ b/bucky/app/bucky.js
@@ -176,7 +176,7 @@ var bucky = module.exports = {
var hasComment = req.body.comment && req.body.comment.length
var hasFile = req.files && req.files.length
if (! hasComment && ! hasFile) {
- console.log(">>> NO FILES OR COMMENT")
+ console.log(">>> no files or comment")
return res.sendStatus(400)
}
next()
@@ -249,6 +249,11 @@ var bucky = module.exports = {
})
})
})
+ Promise.all(promises).then(values => {
+ next()
+ }).catch(err => {
+ console.log(err)
+ })
},
/* MAIL */
diff --git a/bucky/app/router.js b/bucky/app/router.js
index bd72a4d..a793192 100644
--- a/bucky/app/router.js
+++ b/bucky/app/router.js
@@ -5,7 +5,7 @@ var bucky = require('./bucky')
var db = require('../db')
var util = require('../util/util')
var search = require('../search/middleware')
-var multer = require('multer')({ dest:'./uploads/' })
+var multer = require('multer')()
module.exports = function(app){
app.all('*', middleware.ensureLocals)
@@ -89,7 +89,10 @@ module.exports = function(app){
middleware.ensureAuthenticated,
bucky.ensureThread,
// ensure thread privacy
- bucky.createComment,
+ multer.array("files"),
+ bucky.verifyFilesOrComment,
+ bucky.createOptionalFiles,
+ bucky.createOptionalComment,
function(req, res){
res.json({
comment: res.comment
diff --git a/bucky/util/upload.js b/bucky/util/upload.js
index d92183e..242acf0 100644
--- a/bucky/util/upload.js
+++ b/bucky/util/upload.js
@@ -39,7 +39,7 @@ module.exports.put = function (opt) {
filename = uuid.v1() + "." + extension;
}
- var remote_path = "/" + opt.dirname + "/" + filename
+ var remote_path = opt.dirname + filename
if (types && ! extension) {
err = "Unacceptable filetype."
@@ -55,8 +55,8 @@ module.exports.put = function (opt) {
}
opt.acceptable && opt.acceptable(err)
-
- // console.log("upload >", remote_path)
+
+ console.log("upload >", remote_path)
s3.putBuffer(file.buffer, remote_path, {
'Content-Length': file.size,
'Content-Type': file.mimetype,