최동원

.

......@@ -115,4 +115,5 @@ dist
.yarn/install-state.gz
.pnp.*
backend/routes/modules/s3/download/*
\ No newline at end of file
backend/routes/modules/s3/download/*
backend/routes/modules/awsconfig.json
......
......@@ -4,9 +4,6 @@ const router = express.Router();
router.get('/show', function(req, res, next) {
console.log(req.query);
user_id = req.query.id;
let folders = [];
let files = [];
let checkfolder = 'SELECT * FROM folders WHERE user_id = ? AND favorite = 1;';
let checkfiles = 'SELECT * FROM files WHERE user_id = ? AND favorite = 1;';
connection.query(checkfolder, [user_id], function(err, folder, fields) {
......@@ -14,13 +11,11 @@ router.get('/show', function(req, res, next) {
console.log('select error');
res.status(404).send();
} else {
// folders.push(folder);
connection.query(checkfiles, [user_id], function(err, file, fields) {
if (err) {
console.log('select error');
res.status(404).send();
} else {
// files.push(file);
res.status(200).send({
folders: folder,
files: file
......
This diff is collapsed. Click to expand it.
{
"accessKeyId": "ASIAXZL2SWFEWQZ6ZNEU",
"secretAccessKey": "lqUJTmGVElVEJ6RIgacZd1n1ARvVSNrT3JisfpsO",
"sessionToken": "FwoGZXIvYXdzEJv//////////wEaDJAjP1JBdrIxgxqlTyLDAQCU1f4zp5nu4cNnp4U0pRa9ZGqjQKlxjsUWwH478XU6XUNJcN2NMmmZ0Cl8/kHz+GMvmgax7RxSpo0VsaReh/9+1SMcOB3Kcc+sqRivkCBAZAXfaKrdKhuR2WyCe+M+sZKXdqXNpzHPa/6tUVDBNIMC/aH1KMCwi6XChO3M4BBMZNeY73bu7dLcvPVfaBmRQpaTrqTRky7YiwcPHnnMabOLR6k8OX7Uq/gIYx4pWCJ7AGbVts/quDqoK4nWMs+9Ah6A1CjP4Pn2BTItGKcDLysH3w7vuuw+5dcrxRcFawD0sbOGkJ2YX7fvxHPf410Sm4Vyo2Jf94hM",
"region": "us-east-1"
}
"accessKeyId": "",
"secretAccessKey": "",
"sessionToken": "",
"region": "ap-northeast-2"
}
\ No newline at end of file
......
......@@ -2,14 +2,11 @@ const express = require('express');
const router = express.Router();
const AWS = require("aws-sdk");
const moment = require("moment");
AWS.config.loadFromPath(__dirname + "/../modules/awsconfig.json");
const BUCKET_NAME = "hong-s3-cloud";
const s3 = new AWS.S3({
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
region: "ap-northeast-2"
});
const s3 = new AWS.S3();
router.post('/', function(req, res, next) {
......@@ -25,15 +22,15 @@ router.post('/', function(req, res, next) {
if (rows.length != 0) {
let copy_params = {
Bucket: BUCKET_NAME,
CopySource: BUCKET_NAME + '/' + curPath + name,
Key: target_id + '/share/' + name
CopySource: BUCKET_NAME + '/drive/' + curPath + name,
Key: 'drive/' + target_id + '/share/' + name
};
s3.copyObject(copy_params, function(err, data) {
if (err) {
console.log(err, data);
res.status(304).send({ error: "copy error" });
} else {
let values = [name, cur, target_id];
let values = [name, '/share/', target_id];
let sharesql = 'INSERT INTO files (file_name,location,user_id) values (?,?,?);';
connection.query(sharesql, values, function(err3, result, field) {
if (err3) {
......