fix(frontend): s3 file uploader works on public apps too

This commit is contained in:
Ruben Fiszel
2024-10-11 01:08:40 +02:00
parent 7db74eecb9
commit 982dde2b9d
2 changed files with 5 additions and 3 deletions
@@ -34,7 +34,7 @@
}
let fileUploads: Writable<FileUploadData[]> = writable([])
const { app, worldStore, componentControl, runnableComponents } =
const { app, worldStore, componentControl, runnableComponents, workspace } =
getContext<AppViewerContext>('AppViewerContext')
$componentControl[id] = {
@@ -124,6 +124,7 @@
customResourceType="s3"
customClass={css?.container?.class}
customStyle={css?.container?.style}
{workspace}
on:addition={(evt) => {
const curr = outputs.result.peak()
outputs.result.set(curr.concat(evt.detail))
@@ -23,6 +23,7 @@
export let pathTransformer: any = undefined // function taking as input {file: File} and returning a string
export let forceDisplayUploads: boolean = false
export let defaultValue: string | undefined = undefined
export let workspace: string | undefined = undefined
const dispatch = createEventDispatcher()
@@ -154,7 +155,7 @@
})
xhr?.open(
'POST',
`/api/w/${$workspaceStore}/job_helpers/upload_s3_file?${params.toString()}`,
`/api/w/${workspace ?? $workspaceStore}/job_helpers/upload_s3_file?${params.toString()}`,
true
)
xhr?.setRequestHeader('Content-Type', 'application/octet-stream')
@@ -189,7 +190,7 @@
async function deleteFile(fileKey: string) {
await HelpersService.deleteS3File({
workspace: $workspaceStore!,
workspace: workspace ?? $workspaceStore!,
fileKey: fileKey
})
dispatch('deletion', { path: fileKey })