Skip to content

Commit

Permalink
feat: limit file size
Browse files Browse the repository at this point in the history
  • Loading branch information
purocean committed Nov 9, 2023
1 parent 3d19605 commit f9f4ae0
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/main/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ const fileContent = async (ctx: any, next: any) => {

checkPrivateRepo(ctx, repo)

const stat = await file.stat(repo, path)

// limit 30mb
if (stat.size > 30 * 1024 * 1024) {
throw new Error('File is too large.')
}

const content = await file.read(repo, path)

ctx.body = result('ok', 'success', {
Expand Down Expand Up @@ -595,9 +602,9 @@ const server = (port = 3000) => {

app.use(bodyParser({
multipart: true,
formLimit: '20mb',
jsonLimit: '20mb',
textLimit: '20mb',
formLimit: '50mb',
jsonLimit: '50mb',
textLimit: '50mb',
formidable: {
maxFieldsSize: 268435456
}
Expand Down

1 comment on commit f9f4ae0

@vercel
Copy link

@vercel vercel bot commented on f9f4ae0 Nov 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.