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 22:48:38 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
9519ba2af7655e4062293dba618448a2f4149529
9519ba2a
1 parent
3ad8a3dc
updateShow
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
23 deletions
backend/routes/folders.js
backend/routes/folders.js
View file @
9519ba2
...
...
@@ -4,44 +4,83 @@ const AWS = require("aws-sdk");
const
moment
=
require
(
"moment"
);
AWS
.
config
.
loadFromPath
(
__dirname
+
"/../modules/awsconfig.json"
);
const
BUCKET_NAME
=
"
qkrrlqja-test
"
;
const
BUCKET_NAME
=
"
hong-s3-cloud
"
;
let
curPath
=
""
;
let
user_id
=
""
;
let
parentPath
=
""
;
const
s3
=
new
AWS
.
S3
();
// router.get('/show', function(req, res, next) {
// console.log(req.query);
// user_id = req.query.id;
// curPath = req.query.cur;
// if (curPath == '/') {
// parentPath = '/';
// } else {
// let pathSplit = curPath.split('/')
// console.log(pathSplit);
// parentPath = '/';
// for (let i = 1; i < pathSplit.length - 2; i++) {
// parentPath += pathSplit[i];
// parentPath += '/';
// }
// }
// let checkfolder = 'SELECT * FROM folders WHERE location = ? AND user_id = ?;';
// connection.query(checkfolder, [curPath, user_id], function(err, rows, fields) {
// if (err) {
// console.log('select error');
// res.status(400).send({ err: err });
// } else {
// res.status(200).send({
// folders: rows,
// cur: curPath,
// parentPath: parentPath
// })
// }
// });
// });
router
.
get
(
'/show'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
req
.
query
);
user_id
=
req
.
query
.
id
;
curPath
=
req
.
query
.
cur
;
if
(
curPath
==
'/'
)
{
parentPath
=
'/'
;
}
else
{
let
pathSplit
=
curPath
.
split
(
'/'
)
console
.
log
(
pathSplit
);
parentPath
=
'/'
;
for
(
let
i
=
1
;
i
<
pathSplit
.
length
-
2
;
i
++
)
{
parentPath
+=
pathSplit
[
i
];
parentPath
+=
'/'
;
}
}
let
checkfolder
=
'SELECT * FROM folders WHERE location = ? AND user_id = ?;'
;
connection
.
query
(
checkfolder
,
[
curPath
,
user_id
],
function
(
err
,
rows
,
fields
)
{
user_id
=
req
.
query
.
user_id
;
folder_id
=
req
.
query
.
folder_id
;
let
checkfolder
=
'SELECT * FROM folders WHERE folder_id = ? AND user_id = ?;'
;
connection
.
query
(
checkfolder
,
[
curPath
,
user_id
],
function
(
err
,
rows
)
{
if
(
err
)
{
console
.
log
(
'select error'
);
console
.
log
(
'select
1
error'
);
res
.
status
(
400
).
send
({
err
:
err
});
}
else
{
res
.
status
(
200
).
send
({
folders
:
rows
,
cur
:
curPath
,
parentPath
:
parentPath
})
let
location
=
rows
[
0
].
location
+
rows
[
0
].
folder_name
+
'/'
;
if
(
rows
.
length
==
0
)
{
console
.
log
(
'does not exist'
);
res
.
status
(
400
).
send
({
err
:
'does not exist'
});
}
else
{
let
gerFolder
=
'SELECT * FROM folders WHERE location = ? AND user_id = ?;'
;
connection
.
query
(
gerFolder
,
[
location
,
user_id
],
function
(
err
,
folder
)
{
if
(
err
)
{
console
.
log
(
'select2 error'
);
res
.
status
(
400
).
send
({
err
:
err
});
}
else
{
let
gerFile
=
'SELECT * FROM files WHERE location = ? AND user_id = ?;'
;
connection
.
query
(
gerFile
,
[
location
,
user_id
],
function
(
err
,
folder
)
{
if
(
err
)
{
console
.
log
(
'select3 error'
);
res
.
status
(
400
).
send
({
err
:
err
});
}
else
{
res
.
status
(
200
).
send
({
folders
:
folder
,
files
:
file
});
}
});
}
});
}
}
});
});
router
.
post
(
'/makefolder'
,
function
(
req
,
res
,
next
)
{
user_id
=
req
.
body
.
user_id
;
...
...
Please
register
or
login
to post a comment