file size limits
This commit is contained in:
parent
e028311813
commit
d3a18ab079
|
@ -1,4 +1,5 @@
|
||||||
<script>
|
<script>
|
||||||
|
import { notifier } from "builderStore/store/notifications"
|
||||||
import { Heading, Body, Button } from "@budibase/bbui"
|
import { Heading, Body, Button } from "@budibase/bbui"
|
||||||
import { FILE_TYPES } from "constants/backend"
|
import { FILE_TYPES } from "constants/backend"
|
||||||
import api from "builderStore/api"
|
import api from "builderStore/api"
|
||||||
|
@ -7,6 +8,7 @@
|
||||||
const BYTES_IN_MB = 1000000
|
const BYTES_IN_MB = 1000000
|
||||||
|
|
||||||
export let files = []
|
export let files = []
|
||||||
|
export let fileSizeLimit = BYTES_IN_MB * 20
|
||||||
|
|
||||||
let selectedImageIdx = 0
|
let selectedImageIdx = 0
|
||||||
let fileDragged = false
|
let fileDragged = false
|
||||||
|
@ -23,7 +25,17 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
async function processFiles(fileList) {
|
async function processFiles(fileList) {
|
||||||
const filesToProcess = Array.from(fileList).map(({ name, path, size }) => ({
|
const fileArray = Array.from(fileList)
|
||||||
|
|
||||||
|
if (fileArray.some(file => file.size >= fileSizeLimit)) {
|
||||||
|
notifier.danger(
|
||||||
|
`Files cannot exceed ${fileSizeLimit /
|
||||||
|
BYTES_IN_MB}MB. Please try again with smaller files.`
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const filesToProcess = fileArray.map(({ name, path, size }) => ({
|
||||||
name,
|
name,
|
||||||
path,
|
path,
|
||||||
size,
|
size,
|
||||||
|
|
Loading…
Reference in New Issue