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
Hong
2020-06-09 21:36:15 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
aa83525b0d6192b1c08a239a482f75ace36f2bbb
aa83525b
1 parent
a75c14cd
.
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
15 deletions
backend/routes/favorites.js
backend/routes/folders.js
backend/routes/share.js
backend/routes/favorites.js
View file @
aa83525
...
...
@@ -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,16 +11,14 @@ 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
s
,
files
:
file
s
folders
:
folder
,
files
:
file
});
}
});
...
...
backend/routes/folders.js
View file @
aa83525
This diff is collapsed. Click to expand it.
backend/routes/share.js
View file @
aa83525
...
...
@@ -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