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
leeseohyeon
2020-05-31 22:43:27 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
78d4d83080bca3327df7e3eac175a3dde4a86529
78d4d830
1 parent
4a9dd77a
파일 다운로드 수정
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
35 additions
and
12 deletions
backend/package-lock.json
backend/package.json
backend/routes/file/downloadFile.js
backend/routes/modules/awsconfig.json
backend/routes/modules/s3/download/IU/folder1/test4.txt
backend/routes/modules/s3/download/shlee/test100(1).txt
backend/routes/modules/s3/s3.js
front-end/package-lock.json
backend/package-lock.json
View file @
78d4d83
This diff is collapsed. Click to expand it.
backend/package.json
View file @
78d4d83
...
...
@@ -19,7 +19,7 @@
"morgan"
:
"~1.9.1"
,
"mysql"
:
"^2.18.1"
,
"passport"
:
"^0.4.1"
,
"pug"
:
"
2.0.0-beta11
"
,
"pug"
:
"
^3.0.0
"
,
"request"
:
"^2.88.2"
}
}
...
...
backend/routes/file/downloadFile.js
View file @
78d4d83
...
...
@@ -9,6 +9,25 @@ var S3 = require('../modules/s3/s3');
router
.
get
(
'/:name'
,
function
(
req
,
res
,
next
)
{
var
file_name
=
req
.
params
.
name
;
// test.txt
var
user_id
=
req
.
query
.
id
;
var
curPath
=
req
.
query
.
cur
;
// /folder1/folder2/
var
targetFile
=
(
curPath
+
file_name
).
substring
(
1
);
// folder1/folder2/test.txt
var
s3
=
new
AWS
.
S3
();
var
params
=
{
Bucket
:
S3
.
BUCKET_NAME
,
Key
:
'drive/'
+
user_id
+
'/'
+
targetFile
,
};
res
.
attachment
(
file_name
);
var
fileStream
=
s3
.
getObject
(
params
).
createReadStream
();
fileStream
.
pipe
(
res
);
});
/*
// /file/download/:name
router.get('/:name', function (req, res) {
var file_name = req.params.name; // test.txt
...
...
@@ -20,14 +39,18 @@ router.get('/:name', function (req, res) {
S3.downloadFile2(S3.BUCKET_NAME, user_id, targetFile, function (result, downloadDir) {
if (result){
res.download(downloadDir, function (err) {
fs
.
unlink
(
downloadDir
,
function
(
err
)
{
if (err){
console.log(err);
}else{
console.log('download success');
}
);
}
});
}else{
res
.
s
tatus
(
404
).
s
end
({
error
:
'download error'
});
res.send({error: 'download error'});
}
});
});
*/
module
.
exports
=
router
;
\ No newline at end of file
...
...
backend/routes/modules/awsconfig.json
View file @
78d4d83
{
"accessKeyId"
:
"ASIAZQ5XTMMF
77IHPTR6
"
,
"secretAccessKey"
:
"
IIDj5U3n6603WcAOf2OMTj2V6urKuGQaRGXABtVd
"
,
"sessionToken"
:
"FwoGZXIvYXdzEN
H//////////wEaDLvwZHLSr6GbUZyD0yLDAVKxxzxNeyC41xtvOmvV9Xmeor5N/Uy6byi1/D/9K6OoGSwdgPNlyyz5EzCsB3UDWtyWGSmIX9PreX0FX2wnD5/VHDl9QibRMUpXOBlg95BNHrfx0e7Srfn6a1GY8eN9ntiqiv7DuS3jV7I7L9NOE218dxDnt4hul8gStVZ4urSXlz4KUAXLucCbF4y2c/KuDVqKPM/9+MQgnL6f3bHThwNEhZhm4CjyHQYZgB2eGd9HYi95RYC9NglBi1gH60Iao8AELSi8wc32BTItNSdy9ymXld6zjj9OnqNzUZdm+GdCX8qFQ87nzVzmX7kHEOWnK9x+4zTHbGXx
"
,
"accessKeyId"
:
"ASIAZQ5XTMMF
XPQFN3NS
"
,
"secretAccessKey"
:
"
TcMI1ZR/XCHWTp+RXbXDYmoUUb589qOEKVCgrp9s
"
,
"sessionToken"
:
"FwoGZXIvYXdzEN
b//////////wEaDNgXTHMODoBOdUpzkCLDAbECc2/FubNowruTAgVlYoP1DSxpCPyKWCZAgNyMak8XUFwQycZDMvPgj/hl+Jn+a8yn2xktkSZP3yRQ2UcTm0WQeWKt94HzatAXBT17B2BBLZOPjMgFWiG4Rgqw48tyT5po3/M84gs5p+x/0AGh7oVQ9VlqoZcgdCRfXUBD9oQ7xkb74AiZ6kZKu5DSNMyIhzzXFrtIXMK+0La9AmfuAhytmTlG9XXp1UhYzubBajB6b2OW/Ce4yKs7Y7UzRr3LERyLCCj9zM72BTIt+BGOkTrbTV65QeFYRmPbKB7OlRsIfdyd67uKLQfSGmsSgp0SFw7sZKcRRODL
"
,
"region"
:
"us-east-1"
}
\ No newline at end of file
...
...
backend/routes/modules/s3/download/IU/folder1/test4.txt
deleted
100644 → 0
View file @
4a9dd77
안녕
\ No newline at end of file
backend/routes/modules/s3/download/shlee/test100(1).txt
0 → 100644
View file @
78d4d83
[object Object]
\ No newline at end of file
backend/routes/modules/s3/s3.js
View file @
78d4d83
...
...
@@ -106,7 +106,7 @@ var S3 = {
}
else
{
if
(
data
)
{
console
.
log
(
"Get File Success"
);
callback
(
true
,
data
.
body
);
callback
(
true
,
data
.
body
.
toString
()
);
}
}
})
...
...
front-end/package-lock.json
View file @
78d4d83
...
...
@@ -5775,9 +5775,9 @@
}
},
"http-proxy"
:
{
"version"
:
"1.18.
0
"
,
"resolved"
:
"https://registry.npmjs.org/http-proxy/-/http-proxy-1.18.
0
.tgz"
,
"integrity"
:
"sha512-
84I2iJM/n1d4Hdgc6y2+qY5mDaz2PUVjlg9znE9byl+q0uC3DeByqBGReQu5tpLK0TAqTIXScRUV+dg7+bUPp
Q=="
,
"version"
:
"1.18.
1
"
,
"resolved"
:
"https://registry.npmjs.org/http-proxy/-/http-proxy-1.18.
1
.tgz"
,
"integrity"
:
"sha512-
7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5N
Q=="
,
"dev"
:
true
,
"requires"
:
{
"eventemitter3"
:
"^4.0.0"
,
...
...
Please
register
or
login
to post a comment