Skip to content

Can't set fileSize limit to Upload collection #682

Answered by jmikrut
gonzam88 asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @gonzam88 — I see what you're looking to do. And I think this is a totally reasonable request.

As you've noticed, you can only specify global upload filesize limitations, but you can extend the built-in filesize field with a filesize field of your own, complete with a custom validation function that will enforce max upload sizes for you.

Here's the built-in filesize field:

const filesize = {
    name: 'filesize',
    label: 'File Size',
    type: 'number',
    admin: {
      readOnly: true,
      disabled: true,
    },
  };

Just add that to your collection's base level with a custom validation function and then you're off to the races!

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@alexisbrouillette
Comment options

Answer selected by zubricks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants