Issue #339 fixed (upload images from dashboard fails when sails was crashed and rebooted

parent b7a255f6
...@@ -41,9 +41,9 @@ module.exports = { ...@@ -41,9 +41,9 @@ module.exports = {
***************************************************************************/ ***************************************************************************/
ssl: { ssl: {
ca: require('fs').readFileSync(__dirname + '/ssl/ca.crt'), ca: require('fs').readFileSync(__dirname + '/ssl/goddady/gd.yottacode.com.bundle.crt'),
key: require('fs').readFileSync(__dirname + '/ssl/pre.key'), key: require('fs').readFileSync(__dirname + '/ssl/goddady/gd.yottacode.com.key'),
cert: require('fs').readFileSync(__dirname + '/ssl/pre.crt') cert: require('fs').readFileSync(__dirname + '/ssl/goddady/gd.yottacode.com.crt')
}, },
/*************************************************************************** /***************************************************************************
......
...@@ -69,7 +69,9 @@ INSERT INTO `meta_picto` (`id`, `name`, `default`, `domain`, `description`) VALU ...@@ -69,7 +69,9 @@ INSERT INTO `meta_picto` (`id`, `name`, `default`, `domain`, `description`) VALU
-- --
INSERT INTO `source` (`id`, `name`, `description`) VALUES INSERT INTO `source` (`id`, `name`, `description`) VALUES
(1, 'SymbolStix', 'n2y SymbolStix pictograms collection'); (1, 'SymbolStix', 'n2y SymbolStix pictograms collection'),
(2, 'Custom', 'Uploaded pictograms by a given user');
;
-- --
......
...@@ -106,8 +106,11 @@ module.exports = { ...@@ -106,8 +106,11 @@ module.exports = {
return res.json({'status':'GET not allowed'}); return res.json({'status':'GET not allowed'});
// Call to /upload via GET is error // Call to /upload via GET is error
console.log("Nombre de archivo: " + req.body.filename);
console.log("Nombre de carpeta: " + req.body.folder); console.log("Nombre archivo: " + req.body.filename);
console.log("Nombre carpeta: " + req.body.folder);
console.log("Nombre fuente: " + req.body.source);
var fs = require('fs'), path = require('path'); var fs = require('fs'), path = require('path');
req.body.filename = sailsHash.hashCode(req.body.filename + Date().toString()) + '.' + req.body.extension; req.body.filename = sailsHash.hashCode(req.body.filename + Date().toString()) + '.' + req.body.extension;
...@@ -131,6 +134,7 @@ module.exports = { ...@@ -131,6 +134,7 @@ module.exports = {
console.log(files); console.log(files);
var file = dirUpload + '/' + req.body.filename; var file = dirUpload + '/' + req.body.filename;
var interval = setInterval( var interval = setInterval(
...@@ -149,7 +153,7 @@ module.exports = { ...@@ -149,7 +153,7 @@ module.exports = {
// 2) Insert picto with id_owner in picto table // 2) Insert picto with id_owner in picto table
Picto.create(picto).exec(function(err, created){ Picto.create(picto).exec(function(err, created){
if (err) throw err; if (err) return res.serverError(err);
if(created){ if(created){
console.log("Picto created: " + JSON.stringify(created)); console.log("Picto created: " + JSON.stringify(created));
res.json({status:200,file:files[0],picto:created}); res.json({status:200,file:files[0],picto:created});
......
...@@ -159,12 +159,14 @@ dashboardControllers.controller('AddPictoCtrl', function ($scope, $modalInstance ...@@ -159,12 +159,14 @@ dashboardControllers.controller('AddPictoCtrl', function ($scope, $modalInstance
var extension = file.name.split('.').pop(); var extension = file.name.split('.').pop();
var filename = sup.id + file.name; var filename = sup.id + file.name;
console.log("Archivo: " + filename); console.log("Archivo: " + filename);
//file.extra="{'filename': filename, 'extension': extension, 'folder': 'custompictos', 'owner': $scope.sup.id, 'source': '2'}";
$upload.upload({ $upload.upload({
url: '/picto/upload', //upload.php script, node.js route, or servlet url url: '/picto/upload', //upload.php script, node.js route, or servlet url
method: 'POST', // or 'PUT', method: 'POST', // or 'PUT',
// Fields to sent in the body of the request // Fields to be sent in the body of the request
fields: {'filename': filename, 'extension': extension, 'folder': 'custompictos', 'owner': $scope.sup.id, 'source': '1'}, fields: {'filename': filename, 'extension': extension, 'folder': 'custompictos', 'owner': $scope.sup.id, 'source': '2'},
// or ['1.jpg', '2.jpg', ...] // to modify the name of the file(s) // or ['1.jpg', '2.jpg', ...] // to modify the name of the file(s)
file: file, // or list of files ($files) for html5 only file: file, // or list of files ($files) for html5 only
}).progress(function(evt) { }).progress(function(evt) {
...@@ -181,7 +183,10 @@ dashboardControllers.controller('AddPictoCtrl', function ($scope, $modalInstance ...@@ -181,7 +183,10 @@ dashboardControllers.controller('AddPictoCtrl', function ($scope, $modalInstance
// Open modal window to add expression // Open modal window to add expression
$scope.open_exp(data.picto); $scope.open_exp(data.picto);
}); }).error(function(data, status, headers, config) {
console.log("Error uploading: " + data.error);
window.location.replace(window.location.pathname);
});
}else{ }else{
alert("It's only supported JPG, PNG and GIF files"); alert("It's only supported JPG, PNG and GIF files");
} }
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
* For more information on configuring the session, check out: * For more information on configuring the session, check out:
* http://sailsjs.org/#/documentation/reference/sails.config/sails.config.session.html * http://sailsjs.org/#/documentation/reference/sails.config/sails.config.session.html
*/ */
module.exports.session = { module.exports.session = {
/*************************************************************************** /***************************************************************************
...@@ -41,7 +40,7 @@ module.exports.session = { ...@@ -41,7 +40,7 @@ module.exports.session = {
* session store that can be shared across multiple Sails.js servers * * session store that can be shared across multiple Sails.js servers *
***************************************************************************/ ***************************************************************************/
// adapter: 'redis', //adapter: 'redis'
/*************************************************************************** /***************************************************************************
* * * *
......
...@@ -89,7 +89,7 @@ module.exports.sockets = { ...@@ -89,7 +89,7 @@ module.exports.sockets = {
* * * *
***************************************************************************/ ***************************************************************************/
// adapter: 'redis', //adapter: 'socket.io-redis',
// host: '127.0.0.1', // host: '127.0.0.1',
// port: 6379, // port: 6379,
// db: 'sails', // db: 'sails',
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
"keywords": [], "keywords": [],
"dependencies": { "dependencies": {
"bcrypt-nodejs": "0.0.3", "bcrypt-nodejs": "0.0.3",
"connect-redis": "3.0.2",
"ejs": "^0.8.8", "ejs": "^0.8.8",
"forever": "^0.14.1", "forever": "^0.14.1",
"include-all": "~0.1.3", "include-all": "~0.1.3",
...@@ -19,6 +20,7 @@ ...@@ -19,6 +20,7 @@
"sails-mysql": "^0.10.12", "sails-mysql": "^0.10.12",
"sails-test-helper": "^0.3.5", "sails-test-helper": "^0.3.5",
"socket.io": "~1.3.2", "socket.io": "~1.3.2",
"socket.io-redis": "^0.1.4",
"winston": "~1.0.0" "winston": "~1.0.0"
}, },
"scripts": { "scripts": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment