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",
"label": "File name",
"key": "key"
"key": "key",
"nested": true
},
{
"type": "event",

View File

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

View File

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