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-10 19:56:01 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
beca5b88151ce906603098f0f466b1c90c68ff9b
beca5b88
1 parent
f4c8f6a1
휴지통비우기
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
3 deletions
backend/app.js
backend/routes/trashcan.js
backend/app.js
View file @
beca5b8
...
...
@@ -15,6 +15,7 @@ var folderRouter = require('./routes/folders');
var
quickRouter
=
require
(
'./routes/quick'
);
var
favoritesRouter
=
require
(
'./routes/favorites'
);
var
shareRouter
=
require
(
'./routes/share'
);
var
trashcanRouter
=
require
(
'./routes/trashcan'
);
var
passport
=
require
(
'passport'
);
...
...
@@ -64,6 +65,7 @@ app.use('/api/RegistUser', registerRouter);
app
.
use
(
'/api/folder'
,
folderRouter
);
app
.
use
(
'/api/favorites'
,
favoritesRouter
);
app
.
use
(
'/api/share'
,
shareRouter
);
app
.
use
(
'/api/trashcan'
,
trashcanRouter
);
//app.use('/users', usersRouter);
app
.
use
(
'/api/file'
,
fileRouter
);
app
.
use
(
'/api/quick'
,
quickRouter
);
...
...
backend/routes/trashcan.js
View file @
beca5b8
...
...
@@ -3,7 +3,9 @@ const router = express.Router();
const
AWS
=
require
(
"aws-sdk"
);
const
moment
=
require
(
"moment"
);
AWS
.
config
.
loadFromPath
(
__dirname
+
"/modules/awsconfig.json"
);
var
S3
=
require
(
'../modules/s3/s3'
);
var
S3
=
require
(
__dirname
+
'/modules/s3/s3'
);
const
s3
=
new
AWS
.
S3
();
router
.
get
(
'/delfile'
,
function
(
req
,
res
,
next
)
{
var
file_id
=
req
.
query
.
file_id
;
...
...
@@ -20,7 +22,7 @@ router.get('/delfile', function(req, res, next) {
console
.
log
(
'exist error'
);
res
.
send
({
erorr
:
'exist error'
});
}
else
{
var
curPath
=
rows
[
0
].
location
;
var
curPath
=
'/trashcan/'
;
var
file_name
=
rows
[
0
].
file_name
;
var
sourceFile
=
curPath
.
substring
(
1
)
+
file_name
;
...
...
@@ -65,7 +67,6 @@ router.get('/delfolder', function(req, res, next) {
}
else
{
var
curPath
=
'/trashcan/'
var
folder_name
=
rows
[
0
].
folder_name
;
var
sourcefolder
=
curPath
.
substring
(
1
)
+
folder_name
+
'/'
;
var
sql1
=
'DELETE FROM folders WHERE folder_name = (?) AND location=(?) AND user_Id = (?)'
;
connection
.
query
(
sql1
,
[
folder_name
,
curPath
,
user_id
],
function
(
err
)
{
...
...
@@ -97,5 +98,59 @@ router.get('/delfolder', function(req, res, next) {
})
});
router
.
get
(
'/all'
,
function
(
req
,
res
,
next
)
{
var
user_id
=
req
.
query
.
id
;
var
getfolder
=
"SELECT * FROM folders WHERE user_id = ? AND location = ?;"
;
connection
.
query
(
getfolder
,
[
user_id
,
'/trashcan/'
],
function
(
err
,
folders
)
{
if
(
err
)
{
console
.
log
(
'select db error'
);
res
.
send
({
erorr
:
'db select error'
});
}
else
{
var
getfile
=
"SELECT * FROM files WHERE user_id = ? AND location = ?;"
;
connection
.
query
(
getfile
,
[
user_id
,
'/trashcan/'
],
function
(
err
,
files
)
{
if
(
err
)
{
console
.
log
(
'select db error'
);
res
.
send
({
erorr
:
'db select error'
});
}
else
{
for
(
let
i
of
files
)
{
var
sql1
=
'DELETE FROM files WHERE file_id = ?;'
;
var
sourceFile
=
'trashcan/'
+
i
.
file_name
;
connection
.
query
(
sql1
,
[
i
.
file_id
],
function
(
err
)
{
if
(
err
)
{
console
.
log
(
'delete db error'
);
res
.
send
({
erorr
:
'db delete error'
});
}
else
{
S3
.
deleteFile
(
S3
.
BUCKET_NAME
,
user_id
,
sourceFile
,
function
(
result
)
{})
}
})
}
for
(
let
j
of
folders
)
{
var
curPath
=
'/trashcan/'
;
var
sql1
=
'DELETE FROM folders WHERE folder_name = (?) AND location=(?) AND user_Id = (?)'
;
connection
.
query
(
sql1
,
[
j
.
folder_name
,
curPath
,
user_id
],
function
(
err
)
{
if
(
err
)
{
console
.
log
(
'delete db error'
);
res
.
send
({
erorr
:
'db delete error'
});
}
else
{
var
params
=
{
Bucket
:
S3
.
BUCKET_NAME
,
Key
:
'drive/'
+
user_id
+
curPath
+
j
.
folder_name
+
'/'
};
s3
.
deleteObject
(
params
,
function
(
err
,
data
)
{
if
(
err
)
{
res
.
status
(
400
).
send
({
err
:
err
});
}
});
}
});
}
res
.
send
({
success
:
"success"
});
}
});
}
});
});
module
.
exports
=
router
;
\ No newline at end of file
...
...
Please
register
or
login
to post a comment