Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion apps/sim/app/api/tools/file/manage/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
import { isSupportedFileType, parseBuffer } from '@/lib/file-parsers'
import {
getShareForResource,
getSharesForResources,
ShareValidationError,
upsertFileShare,
} from '@/lib/public-shares/share-manager'
Expand Down Expand Up @@ -417,12 +418,30 @@ export const POST = withRouteHandler(async (request: NextRequest) => {
)
}

const shares = await getSharesForResources('file', selectedFileIds)
const privateReadShare = () => ({
visibility: 'private' as const,
url: null,
allowedEmails: [] as string[],
})
const toReadShare = (fileId: string) => {
const share = shares.get(fileId)
if (!share || !share.isActive) return privateReadShare()
return {
visibility: share.authType,
url: share.url,
allowedEmails: share.allowedEmails,
}
}
const userFiles = files
.map((file) => workspaceFileToUserFile(file))
.filter((file): file is NonNullable<ReturnType<typeof workspaceFileToUserFile>> =>
Boolean(file)
)
.concat(selectedInputFiles)
.map((file) => ({ ...file, share: toReadShare(file.id) }))
// Picker/upload entries have only a synthetic id (storage key/URL), so they
// never carry a canonical share — mark them private without a lookup.
.concat(selectedInputFiles.map((file) => ({ ...file, share: privateReadShare() })))

logger.info('Files retrieved', {
count: userFiles.length,
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/blocks/blocks/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1361,7 +1361,7 @@ export const FileV5Block: BlockConfig<FileParserV3Output> = {
files: {
type: 'file[]',
description:
'Workspace file objects (read), fetched file objects (fetch), the compressed archive (compress), or extracted files (decompress)',
'Workspace file objects with share status (read), fetched file objects (fetch), the compressed archive (compress), or extracted files (decompress)',
},
contents: {
type: 'array',
Expand Down
Loading