-
Notifications
You must be signed in to change notification settings - Fork 344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
file upload max size feature #328
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -60,6 +60,13 @@ | |||||||||||||||||||
label="Allowed file types" placeholder="jpg,jpeg,png,gif" | ||||||||||||||||||||
help="Comma separated values, leave blank to allow all file types" | ||||||||||||||||||||
/> | ||||||||||||||||||||
|
||||||||||||||||||||
<text-input name="max_file_size" class="mt-3" :form="field" native-type="number" | ||||||||||||||||||||
:min="1" | ||||||||||||||||||||
:max="mbLimit" | ||||||||||||||||||||
label="Maximum file size (in MB)" :placeholder="`1MB - ${mbLimit}MB`" | ||||||||||||||||||||
help="Set the maximum file size that can be uploaded" | ||||||||||||||||||||
/> | ||||||||||||||||||||
</div> | ||||||||||||||||||||
|
||||||||||||||||||||
<!-- Number Options --> | ||||||||||||||||||||
|
@@ -428,6 +435,9 @@ export default { | |||||||||||||||||||
required: false | ||||||||||||||||||||
} | ||||||||||||||||||||
}, | ||||||||||||||||||||
setup() { | ||||||||||||||||||||
return { currentWorkspace: computed(() => useWorkspacesStore().getCurrent), } | ||||||||||||||||||||
}, | ||||||||||||||||||||
data () { | ||||||||||||||||||||
return { | ||||||||||||||||||||
typesWithoutPlaceholder: ['date', 'checkbox', 'files'], | ||||||||||||||||||||
|
@@ -442,6 +452,9 @@ export default { | |||||||||||||||||||
hasPlaceholder () { | ||||||||||||||||||||
return !this.typesWithoutPlaceholder.includes(this.field.type) | ||||||||||||||||||||
}, | ||||||||||||||||||||
mbLimit() { | ||||||||||||||||||||
return this.form?.max_file_size ?? this.currentWorkspace?.max_file_size | ||||||||||||||||||||
}, | ||||||||||||||||||||
prefillSelectsOptions () { | ||||||||||||||||||||
if (!['select', 'multi_select'].includes(this.field.type)) return {} | ||||||||||||||||||||
|
||||||||||||||||||||
|
@@ -504,6 +517,9 @@ export default { | |||||||||||||||||||
if (['text', 'number', 'url', 'email'].includes(this.field?.type) && !this.field?.max_char_limit) { | ||||||||||||||||||||
this.field.max_char_limit = 2000 | ||||||||||||||||||||
} | ||||||||||||||||||||
if (this.field.type == 'files') { | ||||||||||||||||||||
this.field.max_file_size = Math.min((this.field.max_file_size ?? this.mbLimit), this.mbLimit) | ||||||||||||||||||||
} | ||||||||||||||||||||
Comment on lines
+520
to
+522
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The logic to set + if (this.field.max_file_size > this.mbLimit) {
+ // Notify the user that the max_file_size has been adjusted to the mbLimit
+ } Committable suggestion
Suggested change
|
||||||||||||||||||||
}, | ||||||||||||||||||||
|
||||||||||||||||||||
methods: { | ||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The validation rule for
max_file_size
correctly ensures that the value is numeric and at least 1. However, to prevent potential abuse or unintentional configuration errors, it might be beneficial to also enforce an upper limit. Consider modifying the validation rule to include a reasonable maximum value, such asnumeric|min:1|max:100
(assuming the maximum file size is 100MB as an example). This ensures that file sizes are within a reasonable range.Committable suggestion