Hong

회원가입수정

...@@ -4,6 +4,7 @@ var async = require('async'); ...@@ -4,6 +4,7 @@ var async = require('async');
4 const AWS = require("aws-sdk"); 4 const AWS = require("aws-sdk");
5 AWS.config.loadFromPath(__dirname + "/../modules/awsconfig.json"); 5 AWS.config.loadFromPath(__dirname + "/../modules/awsconfig.json");
6 var cryptoM = require('./../../routes/modules/cryptoM.js'); 6 var cryptoM = require('./../../routes/modules/cryptoM.js');
7 +const moment = require("moment");
7 8
8 const BUCKET_NAME = "hong-s3-cloud"; 9 const BUCKET_NAME = "hong-s3-cloud";
9 const s3 = new AWS.S3(); 10 const s3 = new AWS.S3();
...@@ -34,7 +35,7 @@ router.post('/', function(req, res, next) { ...@@ -34,7 +35,7 @@ router.post('/', function(req, res, next) {
34 connection.query(sql, values, function(err) { 35 connection.query(sql, values, function(err) {
35 if (err) { 36 if (err) {
36 console.log("inserting user failed"); 37 console.log("inserting user failed");
37 - throw err; 38 + res.status(400).send({ err: err });
38 } else { 39 } else {
39 let params = { 40 let params = {
40 Bucket: BUCKET_NAME, 41 Bucket: BUCKET_NAME,
...@@ -45,6 +46,7 @@ router.post('/', function(req, res, next) { ...@@ -45,6 +46,7 @@ router.post('/', function(req, res, next) {
45 s3.putObject(params, function(err, data) { 46 s3.putObject(params, function(err, data) {
46 if (err) { 47 if (err) {
47 console.log('s3 error'); 48 console.log('s3 error');
49 + res.status(400).send({ err: err });
48 } else { 50 } else {
49 let params2 = { 51 let params2 = {
50 Bucket: BUCKET_NAME, 52 Bucket: BUCKET_NAME,
...@@ -55,6 +57,7 @@ router.post('/', function(req, res, next) { ...@@ -55,6 +57,7 @@ router.post('/', function(req, res, next) {
55 s3.putObject(params2, function(err, data) { 57 s3.putObject(params2, function(err, data) {
56 if (err) { 58 if (err) {
57 console.log('s3 error'); 59 console.log('s3 error');
60 + res.status(400).send({ err: err });
58 } else { 61 } else {
59 let params3 = { 62 let params3 = {
60 Bucket: BUCKET_NAME, 63 Bucket: BUCKET_NAME,
...@@ -65,8 +68,27 @@ router.post('/', function(req, res, next) { ...@@ -65,8 +68,27 @@ router.post('/', function(req, res, next) {
65 s3.putObject(params3, function(err, data) { 68 s3.putObject(params3, function(err, data) {
66 if (err) { 69 if (err) {
67 console.log('s3 error'); 70 console.log('s3 error');
71 + res.status(400).send({ err: err });
68 } else { 72 } else {
69 - res.status(200).send('saved'); 73 + let date = moment().format();
74 + let root = '/';
75 + let sql = "INSERT INTO folders (folder_name,location,user_id,created) values (?,?,?,?);";
76 + connection.query(sql, ['share', root, user_id, date], function(err, result, field) {
77 + if (err) {
78 + console.log('insert1 error');
79 + res.status(400).send({ err: err });
80 + } else {
81 + let sql = "INSERT INTO folders (folder_name,location,user_id,created) values (?,?,?,?);";
82 + connection.query(sql, ['trashcan', root, user_id, date], function(err, result, field) {
83 + if (err) {
84 + console.log('insert2 error');
85 + res.status(400).send({ err: err });
86 + } else {
87 + res.status(200).send('saved');
88 + }
89 + });
90 + }
91 + });
70 } 92 }
71 }); 93 });
72 } 94 }
......