Showing
5 changed files
with
12 additions
and
19 deletions
... | @@ -115,4 +115,5 @@ dist | ... | @@ -115,4 +115,5 @@ dist |
115 | .yarn/install-state.gz | 115 | .yarn/install-state.gz |
116 | .pnp.* | 116 | .pnp.* |
117 | 117 | ||
118 | -backend/routes/modules/s3/download/* | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
118 | +backend/routes/modules/s3/download/* | ||
119 | +backend/routes/modules/awsconfig.json | ... | ... |
... | @@ -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,13 +11,11 @@ router.get('/show', function(req, res, next) { | ... | @@ -14,13 +11,11 @@ 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: folder, | 20 | folders: folder, |
26 | files: file | 21 | files: file | ... | ... |
This diff is collapsed. Click to expand it.
1 | { | 1 | { |
2 | - "accessKeyId": "ASIAXZL2SWFEWQZ6ZNEU", | 2 | + "accessKeyId": "", |
3 | - "secretAccessKey": "lqUJTmGVElVEJ6RIgacZd1n1ARvVSNrT3JisfpsO", | 3 | + "secretAccessKey": "", |
4 | - "sessionToken": "FwoGZXIvYXdzEJv//////////wEaDJAjP1JBdrIxgxqlTyLDAQCU1f4zp5nu4cNnp4U0pRa9ZGqjQKlxjsUWwH478XU6XUNJcN2NMmmZ0Cl8/kHz+GMvmgax7RxSpo0VsaReh/9+1SMcOB3Kcc+sqRivkCBAZAXfaKrdKhuR2WyCe+M+sZKXdqXNpzHPa/6tUVDBNIMC/aH1KMCwi6XChO3M4BBMZNeY73bu7dLcvPVfaBmRQpaTrqTRky7YiwcPHnnMabOLR6k8OX7Uq/gIYx4pWCJ7AGbVts/quDqoK4nWMs+9Ah6A1CjP4Pn2BTItGKcDLysH3w7vuuw+5dcrxRcFawD0sbOGkJ2YX7fvxHPf410Sm4Vyo2Jf94hM", | 4 | + "sessionToken": "", |
5 | - "region": "us-east-1" | 5 | + "region": "ap-northeast-2" |
6 | -} | 6 | +} |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -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