Skip to content

Commit f03430a

Browse files
author
aadamgough
committed
fixed supabase tools
1 parent 91fed51 commit f03430a

File tree

4 files changed

+32
-9
lines changed

4 files changed

+32
-9
lines changed

apps/sim/blocks/blocks/supabase.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -596,13 +596,20 @@ Return ONLY the PostgREST filter expression - no explanations, no markdown, no e
596596
},
597597
// Storage Upload fields
598598
{
599-
id: 'path',
600-
title: 'File Path',
599+
id: 'fileName',
600+
title: 'File Name',
601601
type: 'short-input',
602-
placeholder: 'folder/file.jpg',
602+
placeholder: 'myfile.pdf',
603603
condition: { field: 'operation', value: 'storage_upload' },
604604
required: true,
605605
},
606+
{
607+
id: 'path',
608+
title: 'Folder Path (optional)',
609+
type: 'short-input',
610+
placeholder: 'folder/subfolder/',
611+
condition: { field: 'operation', value: 'storage_upload' },
612+
},
606613
{
607614
id: 'fileContent',
608615
title: 'File Content',
@@ -1065,10 +1072,10 @@ Return ONLY the PostgREST filter expression - no explanations, no markdown, no e
10651072
countType: { type: 'string', description: 'Count type: exact, planned, or estimated' },
10661073
// Storage operation inputs
10671074
bucket: { type: 'string', description: 'Storage bucket name' },
1068-
path: { type: 'string', description: 'File path in storage' },
1075+
path: { type: 'string', description: 'File or folder path in storage' },
10691076
fileContent: { type: 'string', description: 'File content (base64 for binary)' },
10701077
contentType: { type: 'string', description: 'MIME type of the file' },
1071-
fileName: { type: 'string', description: 'Optional filename override for downloaded file' },
1078+
fileName: { type: 'string', description: 'File name for upload or download override' },
10721079
upsert: { type: 'boolean', description: 'Whether to overwrite existing file' },
10731080
download: { type: 'boolean', description: 'Whether to force download' },
10741081
paths: { type: 'array', description: 'Array of file paths' },

apps/sim/tools/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,8 @@ async function handleInternalRequest(
747747
url: fullUrl,
748748
json: () => response.json(),
749749
text: () => response.text(),
750+
arrayBuffer: () => response.arrayBuffer(),
751+
blob: () => response.blob(),
750752
} as Response
751753

752754
const data = await tool.transformResponse(mockResponse, params)

apps/sim/tools/supabase/storage_upload.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,17 @@ export const storageUploadTool: ToolConfig<
2626
visibility: 'user-or-llm',
2727
description: 'The name of the storage bucket',
2828
},
29-
path: {
29+
fileName: {
3030
type: 'string',
3131
required: true,
3232
visibility: 'user-or-llm',
33-
description: 'The path where the file will be stored (e.g., "folder/file.jpg")',
33+
description: 'The name of the file (e.g., "document.pdf", "image.jpg")',
34+
},
35+
path: {
36+
type: 'string',
37+
required: false,
38+
visibility: 'user-or-llm',
39+
description: 'Optional folder path (e.g., "folder/subfolder/")',
3440
},
3541
fileContent: {
3642
type: 'string',
@@ -60,7 +66,14 @@ export const storageUploadTool: ToolConfig<
6066

6167
request: {
6268
url: (params) => {
63-
return `https://${params.projectId}.supabase.co/storage/v1/object/${params.bucket}/${params.path}`
69+
// Combine folder path and fileName, ensuring proper formatting
70+
let fullPath = params.fileName
71+
if (params.path) {
72+
// Ensure path ends with / and doesn't have double slashes
73+
const folderPath = params.path.endsWith('/') ? params.path : `${params.path}/`
74+
fullPath = `${folderPath}${params.fileName}`
75+
}
76+
return `https://${params.projectId}.supabase.co/storage/v1/object/${params.bucket}/${fullPath}`
6477
},
6578
method: 'POST',
6679
headers: (params) => {

apps/sim/tools/supabase/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ export interface SupabaseStorageUploadParams {
132132
apiKey: string
133133
projectId: string
134134
bucket: string
135-
path: string
135+
fileName: string
136+
path?: string
136137
fileContent: string
137138
contentType?: string
138139
upsert?: boolean

0 commit comments

Comments
 (0)