Showing
3 changed files
with
7 additions
and
15 deletions
... | @@ -4,9 +4,6 @@ const router = express.Router(); | ... | @@ -4,9 +4,6 @@ const router = express.Router(); |
4 | router.get('/show', function(req, res, next) { | 4 | router.get('/show', function(req, res, next) { |
5 | console.log(req.query); | 5 | console.log(req.query); |
6 | user_id = req.query.id; | 6 | user_id = req.query.id; |
7 | - let folders = []; | ||
8 | - let files = []; | ||
9 | - | ||
10 | let checkfolder = 'SELECT * FROM folders WHERE user_id = ? AND favorite = 1;'; | 7 | let checkfolder = 'SELECT * FROM folders WHERE user_id = ? AND favorite = 1;'; |
11 | let checkfiles = 'SELECT * FROM files WHERE user_id = ? AND favorite = 1;'; | 8 | let checkfiles = 'SELECT * FROM files WHERE user_id = ? AND favorite = 1;'; |
12 | connection.query(checkfolder, [user_id], function(err, folder, fields) { | 9 | connection.query(checkfolder, [user_id], function(err, folder, fields) { |
... | @@ -14,16 +11,14 @@ router.get('/show', function(req, res, next) { | ... | @@ -14,16 +11,14 @@ router.get('/show', function(req, res, next) { |
14 | console.log('select error'); | 11 | console.log('select error'); |
15 | res.status(404).send(); | 12 | res.status(404).send(); |
16 | } else { | 13 | } else { |
17 | - folders.push(folder); | ||
18 | connection.query(checkfiles, [user_id], function(err, file, fields) { | 14 | connection.query(checkfiles, [user_id], function(err, file, fields) { |
19 | if (err) { | 15 | if (err) { |
20 | console.log('select error'); | 16 | console.log('select error'); |
21 | res.status(404).send(); | 17 | res.status(404).send(); |
22 | } else { | 18 | } else { |
23 | - files.push(file); | ||
24 | res.status(200).send({ | 19 | res.status(200).send({ |
25 | - folders: folders, | 20 | + folders: folder, |
26 | - files: files | 21 | + files: file |
27 | }); | 22 | }); |
28 | } | 23 | } |
29 | }); | 24 | }); | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -2,14 +2,11 @@ const express = require('express'); | ... | @@ -2,14 +2,11 @@ const express = require('express'); |
2 | const router = express.Router(); | 2 | const router = express.Router(); |
3 | const AWS = require("aws-sdk"); | 3 | const AWS = require("aws-sdk"); |
4 | const moment = require("moment"); | 4 | const moment = require("moment"); |
5 | +AWS.config.loadFromPath(__dirname + "/../modules/awsconfig.json"); | ||
5 | 6 | ||
6 | const BUCKET_NAME = "hong-s3-cloud"; | 7 | const BUCKET_NAME = "hong-s3-cloud"; |
7 | 8 | ||
8 | -const s3 = new AWS.S3({ | 9 | +const s3 = new AWS.S3(); |
9 | - accessKeyId: process.env.AWS_ACCESS_KEY_ID, | ||
10 | - secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY, | ||
11 | - region: "ap-northeast-2" | ||
12 | -}); | ||
13 | 10 | ||
14 | 11 | ||
15 | router.post('/', function(req, res, next) { | 12 | router.post('/', function(req, res, next) { |
... | @@ -25,15 +22,15 @@ router.post('/', function(req, res, next) { | ... | @@ -25,15 +22,15 @@ router.post('/', function(req, res, next) { |
25 | if (rows.length != 0) { | 22 | if (rows.length != 0) { |
26 | let copy_params = { | 23 | let copy_params = { |
27 | Bucket: BUCKET_NAME, | 24 | Bucket: BUCKET_NAME, |
28 | - CopySource: BUCKET_NAME + '/' + curPath + name, | 25 | + CopySource: BUCKET_NAME + '/drive/' + curPath + name, |
29 | - Key: target_id + '/share/' + name | 26 | + Key: 'drive/' + target_id + '/share/' + name |
30 | }; | 27 | }; |
31 | s3.copyObject(copy_params, function(err, data) { | 28 | s3.copyObject(copy_params, function(err, data) { |
32 | if (err) { | 29 | if (err) { |
33 | console.log(err, data); | 30 | console.log(err, data); |
34 | res.status(304).send({ error: "copy error" }); | 31 | res.status(304).send({ error: "copy error" }); |
35 | } else { | 32 | } else { |
36 | - let values = [name, cur, target_id]; | 33 | + let values = [name, '/share/', target_id]; |
37 | let sharesql = 'INSERT INTO files (file_name,location,user_id) values (?,?,?);'; | 34 | let sharesql = 'INSERT INTO files (file_name,location,user_id) values (?,?,?);'; |
38 | connection.query(sharesql, values, function(err3, result, field) { | 35 | connection.query(sharesql, values, function(err3, result, field) { |
39 | if (err3) { | 36 | if (err3) { | ... | ... |
-
Please register or login to post a comment