Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
337
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
23
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TransFem.org
Sharkey
Commits
a7762aea
Commit
a7762aea
authored
7 years ago
by
otofune
Browse files
Options
Downloads
Patches
Plain Diff
file - if 'name' param given, validate
parent
8e62cc1e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/file/server.ts
+7
-1
7 additions, 1 deletion
src/file/server.ts
with
7 additions
and
1 deletion
src/file/server.ts
+
7
−
1
View file @
a7762aea
...
...
@@ -86,7 +86,7 @@ function send(data: Buffer, type: string, req: express.Request, res: express.Res
}
}
async
function
sendFileById
(
req
:
express
.
Request
,
res
:
express
.
Response
):
Promise
<
void
>
{
async
function
sendFileById
(
req
:
express
.
Request
,
res
:
express
.
Response
):
Promise
<
void
>
{
// Validate id
if
(
!
mongodb
.
ObjectID
.
isValid
(
req
.
params
.
id
))
{
res
.
status
(
400
).
send
(
'
incorrect id
'
);
...
...
@@ -96,6 +96,12 @@ async function sendFileById (req: express.Request, res: express.Response): Promi
const
fileId
=
new
mongodb
.
ObjectID
(
req
.
params
.
id
);
const
file
=
await
DriveFile
.
findOne
({
_id
:
fileId
});
// validate name
if
(
req
.
params
.
name
!==
undefined
&&
req
.
params
.
name
!==
file
.
metadata
.
name
)
{
res
.
status
(
404
).
send
(
'
there is no file has given name
'
);
return
;
}
if
(
file
==
null
)
{
res
.
status
(
404
).
sendFile
(
`
${
__dirname
}
/assets/dummy.png`
);
return
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment