Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

Commit

Permalink
Added server side support for Importing Files
Browse files Browse the repository at this point in the history
Signed-off-by: Kamidi Preetham <kamidi@live.com>
  • Loading branch information
Kamidi Preetham committed Jul 6, 2016
1 parent d2405d1 commit 3b78ea8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
14 changes: 14 additions & 0 deletions server/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,20 @@
}
});

router.post('/api/file/upload', function(req, res) {
upload(req, res, function(err) {
if(req.hasOwnProperty('file')) {
if (err) {
return res.status(400).send('File Upload Failed: ' + err);
} else {
return res.sendStatus(0);
}
} else {
return res.status(400).send('Error: Form cannot be empty');
}
})
});

router.post('/api/git/repo/delete/file', function (req, res) {
var file_path = req.body.params.file_path;
if (!file_path) {
Expand Down
11 changes: 11 additions & 0 deletions server/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,17 @@ module.exports = function () {
}
};

this.storage = multer.diskStorage({
destination: function(req, file, callback) {
callback(null, String(req.body.upload_path))
},
filename: function(req, file, callback) {
callback(null, file.originalname)
}
});

this.upload = multer({storage: storage }).single('file');

this.getServerName = function(repo_url) {
var url_array = repo_url.split("/");
var name = url_array.pop();
Expand Down

0 comments on commit 3b78ea8

Please sign in to comment.