Merge pull request #15179 from Budibase/s3-upload-fixes

S3Upload UI fixes
This commit is contained in:
deanhannigan 2025-01-13 15:36:48 +00:00 committed by GitHub
commit c79ebad924
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 21 additions and 3 deletions

View File

@ -5139,7 +5139,8 @@
{ {
"type": "text", "type": "text",
"label": "File name", "label": "File name",
"key": "key" "key": "key",
"nested": true
}, },
{ {
"type": "event", "type": "event",

View File

@ -2,6 +2,8 @@
import Field from "./Field.svelte" import Field from "./Field.svelte"
import { CoreDropzone, ProgressCircle, Helpers } from "@budibase/bbui" import { CoreDropzone, ProgressCircle, Helpers } from "@budibase/bbui"
import { getContext, onMount, onDestroy } from "svelte" import { getContext, onMount, onDestroy } from "svelte"
import { builderStore } from "stores/builder.js"
import { processStringSync } from "@budibase/string-templates"
export let datasourceId export let datasourceId
export let bucket export let bucket
@ -12,6 +14,8 @@
export let validation export let validation
export let onChange export let onChange
const context = getContext("context")
let fieldState let fieldState
let fieldApi let fieldApi
let localFiles = [] let localFiles = []
@ -42,6 +46,9 @@
// Process the file input and return a serializable structure expected by // Process the file input and return a serializable structure expected by
// the dropzone component to display the file // the dropzone component to display the file
const processFiles = async fileList => { const processFiles = async fileList => {
if ($builderStore.inBuilder) {
return []
}
return await new Promise(resolve => { return await new Promise(resolve => {
if (!fileList?.length) { if (!fileList?.length) {
return [] return []
@ -78,9 +85,15 @@
} }
const upload = async () => { const upload = async () => {
const processedFileKey = processStringSync(key, $context)
loading = true loading = true
try { try {
const res = await API.externalUpload(datasourceId, bucket, key, data) const res = await API.externalUpload(
datasourceId,
bucket,
processedFileKey,
data
)
notificationStore.actions.success("File uploaded successfully") notificationStore.actions.success("File uploaded successfully")
loading = false loading = false
return res return res
@ -126,7 +139,7 @@
bind:fieldApi bind:fieldApi
defaultValue={[]} defaultValue={[]}
> >
<div class="content"> <div class="content" class:builder={$builderStore.inBuilder}>
{#if fieldState} {#if fieldState}
<CoreDropzone <CoreDropzone
value={localFiles} value={localFiles}
@ -149,6 +162,9 @@
</Field> </Field>
<style> <style>
.content.builder :global(.spectrum-Dropzone) {
pointer-events: none;
}
.content { .content {
position: relative; position: relative;
} }

View File

@ -100,6 +100,7 @@ export const buildAttachmentEndpoints = (
body: data, body: data,
json: false, json: false,
external: true, external: true,
parseResponse: response => response as any,
}) })
return { publicUrl } return { publicUrl }
}, },