diff --git a/packages/bbui/src/Form/Core/Dropzone.svelte b/packages/bbui/src/Form/Core/Dropzone.svelte index e9ee75bd8b..0b6a9bb94f 100644 --- a/packages/bbui/src/Form/Core/Dropzone.svelte +++ b/packages/bbui/src/Form/Core/Dropzone.svelte @@ -159,8 +159,10 @@ {#if selectedImage.size}
{#if selectedImage.size <= BYTES_IN_MB} - {`${selectedImage.size / BYTES_IN_KB} KB`} - {:else}{`${selectedImage.size / BYTES_IN_MB} MB`}{/if} + {`${(selectedImage.size / BYTES_IN_KB).toFixed(1)} KB`} + {:else}{`${(selectedImage.size / BYTES_IN_MB).toFixed( + 1 + )} MB`}{/if}
{/if} {#if !disabled} @@ -203,8 +205,8 @@ {#if file.size}
{#if file.size <= BYTES_IN_MB} - {`${file.size / BYTES_IN_KB} KB`} - {:else}{`${file.size / BYTES_IN_MB} MB`}{/if} + {`${(file.size / BYTES_IN_KB).toFixed(1)} KB`} + {:else}{`${(file.size / BYTES_IN_MB).toFixed(1)} MB`}{/if}
{/if} {#if !disabled} diff --git a/packages/builder/src/components/backend/DataTable/RowFieldControl.svelte b/packages/builder/src/components/backend/DataTable/RowFieldControl.svelte index 9d52cb815e..ea1161fe9b 100644 --- a/packages/builder/src/components/backend/DataTable/RowFieldControl.svelte +++ b/packages/builder/src/components/backend/DataTable/RowFieldControl.svelte @@ -14,6 +14,7 @@ import LinkedRowSelector from "components/common/LinkedRowSelector.svelte" import Editor from "../../integration/QueryEditor.svelte" import { ValidFileExtensions } from "@budibase/shared-core" + import { admin } from "stores/portal" export let defaultValue export let meta @@ -21,7 +22,9 @@ export let readonly export let error - let validExtensions = ValidFileExtensions.map(ext => `.${ext}`).join(", ") + let validExtensions = $admin.cloud + ? ValidFileExtensions.map(ext => `.${ext}`).join(", ") + : "*" const resolveTimeStamp = timestamp => { if (!timestamp) { diff --git a/packages/server/src/api/controllers/static/index.ts b/packages/server/src/api/controllers/static/index.ts index 984cb16c06..e8d403ad12 100644 --- a/packages/server/src/api/controllers/static/index.ts +++ b/packages/server/src/api/controllers/static/index.ts @@ -1,3 +1,5 @@ +import { ValidFileExtensions } from "@budibase/shared-core" + require("svelte/register") import { join } from "../../../utilities/centralPath" @@ -17,6 +19,7 @@ import fs from "fs" import sdk from "../../../sdk" import * as pro from "@budibase/pro" import { App, Ctx } from "@budibase/types" +import environment from "../../../environment" const send = require("koa-send") @@ -78,6 +81,17 @@ export const uploadFile = async function (ctx: Ctx) { const uploads = files.map(async (file: any) => { const fileExtension = [...file.name.split(".")].pop() + if ( + !environment.SELF_HOSTED && + !ValidFileExtensions.includes(fileExtension) + ) { + ctx.throw( + 400, + `Invalid file extension. Valid extensions are: ${ValidFileExtensions.join( + ", " + )}` + ) + } // filenames converted to UUIDs so they are unique const processedFileName = `${uuid.v4()}.${fileExtension}`