Private
Private

Reputation: 2694

Is there a file size limit or extension limit in wagtail?

I have a very simple model (Product) which is used as an InlinePanel in a page.

Product has a FileField which works fine as long as I upload small files, but as soon as I upload a large file (>5MB), I somehow get an CSRF error. Both on local and on production.

It is not an issue with nginx max upload size.

Is there a file size limit or extension limit in wagtail?

Upvotes: 2

Views: 2937

Answers (2)

Private
Private

Reputation: 2694

In some cases, you might have configured a temporary directory for large file downloads.

In my case this was:

 FILE_UPLOAD_TEMP_DIR = str(ROOT_DIR('tmp'))

If this directory is not created, you cannot upload large files, but small files will work fine. Simply create the directory locally and on production.

This bug is extremely hard to debug, as the wagtail admin interface will simply say that the upload fails, and somehow it will even yield a CSRF error.

Upvotes: 0

Kalob Taulien
Kalob Taulien

Reputation: 1918

Yes, this comes baked into wagtail. If you add the following setting to your settings.py (or whatever your main settings file is), you'll be able to restrict upload sizes.

WAGTAILIMAGES_MAX_UPLOAD_SIZE = 15 * 1024 * 1024   # 15mb

The docs briefly cover this, too. Here's the link: http://docs.wagtail.io/en/v2.1.1/advanced_topics/settings.html#maximum-upload-size-for-images

If you need to change the file size from 15mb to anything else, just change that 15 in the settings line to the number of mb you want to limit it to.

Upvotes: 4

Related Questions