Skip to content

Commit 6a886d1

Browse files
authored
Merge pull request #362 from OpenGeoscience/upload-size-limit
Add a size limit to file upload UI
2 parents 5cea6dc + 0e01660 commit 6a886d1

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

web/src/components/projects/DatasetUpload.vue

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ const mandatoryRule = [
4343
(v: any) => (v ? true : "Input required.")
4444
];
4545
const acceptTypes = '.json,.geojson,.tif,.tiff,.zip'
46+
const maxFileSize = 2000000000
47+
const fileUploadRules = [(fileset: File[]) => {
48+
if (fileset.some((f) => f.size > maxFileSize)) {
49+
return 'File Upload cannot be greater than 2 GB.'
50+
}
51+
}]
4652
4753
const similarExisting = computed(() => {
4854
return props.allDatasets.filter((d) => {
@@ -57,7 +63,8 @@ const valid = computed(() => {
5763
return (
5864
name.value && description.value && category.value &&
5965
layers.value.length > 0 && layers.value.every((l) => {
60-
return l.name && l.files.length && (
66+
return l.name && l.files.length &&
67+
fileUploadRules.every((rule) => rule(l.files) === undefined) && (
6168
l.frame_method === 'single' || l.frame_property
6269
)
6370
})
@@ -228,7 +235,7 @@ watch(open, () => {
228235
<v-icon icon="mdi-information-outline" color="primary" class="upload-info-icon"
229236
v-tooltip="'Upload multiple files to create a sequence of frames, or upload a single file to optionally split into frames.'" />
230237
<v-file-upload v-model="layer.files" density="compact" class="mt-2" multiple
231-
clearable :accept="acceptTypes"
238+
clearable :accept="acceptTypes" show-size :rules="fileUploadRules"
232239
style="background-color: rgb(var(--v-theme-secondary)); padding: 10px"
233240
@update:model-value="() => { layer.frame_method = 'single'; layer.frame_property = undefined }">
234241
<template v-slot:icon>

0 commit comments

Comments
 (0)