Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2020-1-CloudComputing
/
D_Team_Khuloud
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
최동원
2020-06-09 22:52:51 +0900
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
d88f6a1e8daf23d0724df52c718f56603587301a
d88f6a1e
2 parents
b51971ac
9519ba2a
.
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
10 additions
and
17 deletions
.gitignore
backend/routes/favorites.js
backend/routes/folders.js
backend/routes/modules/awsconfig.json
backend/routes/share.js
.gitignore
View file @
d88f6a1
...
...
@@ -116,3 +116,4 @@ dist
.pnp.*
backend/routes/modules/s3/download/*
backend/routes/modules/awsconfig.json
...
...
backend/routes/favorites.js
View file @
d88f6a1
...
...
@@ -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
...
...
backend/routes/folders.js
View file @
d88f6a1
This diff is collapsed. Click to expand it.
backend/routes/modules/awsconfig.json
View file @
d88f6a1
{
"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
...
...
backend/routes/share.js
View file @
d88f6a1
...
...
@@ -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
)
{
...
...
Please
register
or
login
to post a comment