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-06-09 03:35:42 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
2b1c4d684c65343e229628d356ac56d02ceb8d4d
2b1c4d68
1 parent
61b6572b
파일 다운로드 에러 처리
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
10 deletions
backend/routes/file/downloadFile.js
backend/routes/modules/s3/s3.js
backend/routes/file/downloadFile.js
View file @
2b1c4d6
...
...
@@ -16,6 +16,7 @@ router.get('/:name', function (req, res) {
var
user_id
=
req
.
query
.
id
;
var
targetFile
=
curPath
.
substring
(
1
)
+
file_name
;
// folder1/folder2/test.txt
console
.
log
(
targetFile
);
S3
.
downloadFile3
(
S3
.
BUCKET_NAME
,
user_id
,
targetFile
,
function
(
result
,
downloadDir
)
{
...
...
@@ -29,7 +30,7 @@ router.get('/:name', function (req, res) {
}
})
}
else
{
res
.
send
({
err
:
'
download error
'
})
res
.
send
({
err
:
'
no such file
'
})
}
})
});
...
...
backend/routes/modules/s3/s3.js
View file @
2b1c4d6
...
...
@@ -166,16 +166,23 @@ var S3 = {
Bucket
:
bucketName
,
Key
:
'drive/'
+
userId
+
'/'
+
targetFile
};
try
{
var
stream
=
s3
.
getObject
(
params
).
createReadStream
().
pipe
(
file
);
stream
.
on
(
'end'
,
function
(){
console
.
log
(
'end!'
);
callback
(
true
,
tempDownloadDir
);
});
}
catch
(
err
){
console
.
log
(
'no such file'
,
err
);
s3
.
getObject
(
params
)
.
createReadStream
()
.
on
(
'error'
,
function
(
e
){
callback
(
false
);
}
})
.
pipe
(
file
)
.
on
(
'close'
,
function
(){
callback
(
true
,
tempDownloadDir
);
})
//try {
// var file = s3.getObject(params);
// file.createReadStream().pipe(file);
// callback(true, tempDownloadDir);
//} catch (err) {
// console.log('no such file');
// callback(false);
//}
}
else
{
callback
(
false
);
}
...
...
Please
register
or
login
to post a comment