Skip to content

Commit

Permalink
Fix maxFileSize parameter being ignored (#9348)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Cousens <dcousens@users.noreply.github.com>
  • Loading branch information
dcousens and dcousens authored Oct 17, 2024
1 parent 70eaf68 commit 86c5db3
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/fix-file-size.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@keystone-6/core": patch
---

Fixes `serxer.maxFileSize` parameter being ignored
4 changes: 4 additions & 0 deletions examples/assets-local/keystone.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { config } from '@keystone-6/core'
import { lists } from './schema'
import bytes from 'bytes'

export default config({
db: {
Expand All @@ -10,6 +11,9 @@ export default config({
prismaClientPath: 'node_modules/myprisma',
},
lists,
server: {
maxFileSize: bytes('40Mb')
},
storage: {
my_images: {
kind: 'local',
Expand Down
4 changes: 3 additions & 1 deletion examples/assets-local/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
},
"dependencies": {
"@keystone-6/core": "^6.3.0",
"@prisma/client": "5.19.0"
"@prisma/client": "5.19.0",
"bytes": "^3.1.1"
},
"devDependencies": {
"@types/bytes": "^3.1.1",
"prisma": "5.19.0",
"typescript": "^5.5.0"
}
Expand Down
4 changes: 4 additions & 0 deletions examples/assets-s3/keystone.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dotenv/config'
import { config } from '@keystone-6/core'
import { lists } from './schema'
import bytes from 'bytes'

const {
S3_BUCKET_NAME: bucketName = 'keystone-test',
Expand All @@ -18,6 +19,9 @@ export default config({
prismaClientPath: 'node_modules/myprisma',
},
lists,
server: {
maxFileSize: bytes('8Mb')
},
storage: {
my_images: {
kind: 's3',
Expand Down
2 changes: 2 additions & 0 deletions examples/assets-s3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
"dependencies": {
"@keystone-6/core": "^6.3.0",
"@prisma/client": "5.19.0",
"bytes": "^3.1.1",
"dotenv": "^16.0.0"
},
"devDependencies": {
"@types/bytes": "^3.1.1",
"prisma": "5.19.0",
"typescript": "^5.5.0"
}
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/lib/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ export function resolveDefaults <TypeInfo extends BaseKeystoneTypeInfo> (config:
},
lists: injectDefaults(config, defaultIdField),
server: {
maxFileSize: 200 * 1024 * 1024, // 200 MiB
...config.server,
maxFileSize: config.server?.maxFileSize ?? (200 * 1024 * 1024), // 200 MiB
extendExpressApp: config.server?.extendExpressApp ?? noop,
extendHttpServer: config.server?.extendHttpServer ?? noop,
cors,
Expand Down
12 changes: 12 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 86c5db3

Please sign in to comment.