From c86f21e6eb87caa4e66fd7a43b1b6428abfad05a Mon Sep 17 00:00:00 2001
From: Jure Triglav <juretriglav@gmail.com>
Date: Fri, 11 Dec 2015 22:32:30 +0100
Subject: [PATCH] File upload is working. Also, celebrations! Repositories are
 open!

---
 app/containers/Admin/EditorWrapper.jsx | 4 +++-
 routes/api.js                          | 3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/app/containers/Admin/EditorWrapper.jsx b/app/containers/Admin/EditorWrapper.jsx
index 1b3ccc84d..82d974687 100644
--- a/app/containers/Admin/EditorWrapper.jsx
+++ b/app/containers/Admin/EditorWrapper.jsx
@@ -21,7 +21,9 @@ export default class EditorWrapper extends React.Component {
 
     fetch('/api/upload', { method: 'POST', body: form })
       .then(function (res) {
-        return callback(null, null)
+        return res.text()
+      }).then(function (text) {
+        return callback(null, text)
       })
   }
   render () {
diff --git a/routes/api.js b/routes/api.js
index 41a1b2cc5..8a09734c6 100644
--- a/routes/api.js
+++ b/routes/api.js
@@ -163,7 +163,8 @@ var upload = multer({
   limits: {fileSize: 1000000, files: 1}
 })
 api.post('/upload', upload.single('file'), function (req, res, next) {
-  return req.file.path
+  console.log(req.file)
+  return res.send(req.file.path.replace(/^public/, ''))
 })
 
 module.exports = api
-- 
GitLab