<p>There's no way for the moment to limit filesize by Volume, but your can create a custom module with the <code>EVENT_BEFORE_SAVE</code> hooked on Assets.</p>

<p>Here's a <a href="https://craftcms.stackexchange.com/questions/23261/how-to-set-different-file-size-upload-limits-for-different-asset-sources">related post</a>.</p>

CC BY-SA 4.0
2019-02-14T15:03:16.190Z
'Limit' for Craft fields refers to the maximum number of files that can be assigned to a field, not the file size (or total file size) of those files.
Jamie Wade
CC BY-SA 4.0
2019-02-14T15:26:10.193Z
Not enough coffee this morning -_-
Maxime Lafrenière
CC BY-SA 4.0
2019-02-14T14:37:25.947Z
2019-02-14T16:22:40.047Z
2019-02-14T16:22:40.047Z
Maxime Lafrenière
<p>I have a use case where I want to limit the allowed file size for a certain Assets Volume to 20kb. All other volumes should be allowed files no matter the size.</p>

<p>I have looked at some other threads already that suggest developing a plugin to do this, or use the Yii event system for file uploads. </p>

<p>I have made other simple plugins before that interacted with entries, but I cannot understand how to make a plugin that latches onto the file uploading event.</p>

<p>Does anyone have any good documentation for where to begin with this? It is version 3.0</p>

<assets><limit>
Restricting file size for an Assets Volume
# Restricting file size for an Assets Volume

(Asked by: username_0 on 2019-02-14)

I have a use case where I want to limit the allowed file size for a certain Assets Volume to 20kb. All other volumes should be allowed files no matter the size.

I have looked at some other threads already that suggest developing a plugin to do this, or use the Yii event system for file uploads.

I have made other simple plugins before that interacted with entries, but I cannot understand how to make a plugin that latches onto the file uploading event.

Does anyone have any good documentation for where to begin with this? It is version 3.0

**Tags:** assets, limit


---

## 1 answers

### Answer by username_1 on 2019-02-14. Score: 2

There's no way for the moment to limit filesize by Volume, but your can create a custom module with the `EVENT_BEFORE_SAVE` hooked on Assets.

Here's a [related post](https://craftcms.stackexchange.com/questions/23261/how-to-set-different-file-size-upload-limits-for-different-asset-sources).

> **Comments:**
> **username_2**: 'Limit' for Craft fields refers to the maximum number of files that can be assigned to a field, not the file size (or total file size) of those files.  
> **username_1**: Not enough coffee this morning -_-  

---

