fix(bot): 🐛 Accept file upload without fileType
This commit is contained in:
@ -23,14 +23,15 @@ const handler = async (
|
|||||||
const fileType = req.query.fileType as string | undefined
|
const fileType = req.query.fileType as string | undefined
|
||||||
const typebotId = req.query.typebotId as string
|
const typebotId = req.query.typebotId as string
|
||||||
const blockId = req.query.blockId as string
|
const blockId = req.query.blockId as string
|
||||||
if (!filePath || !fileType) return badRequest(res)
|
if (!filePath) return badRequest(res, 'Missing filePath or fileType')
|
||||||
const typebot = (await prisma.publicTypebot.findFirst({
|
const typebot = (await prisma.publicTypebot.findFirst({
|
||||||
where: { typebotId },
|
where: { typebotId },
|
||||||
})) as unknown as PublicTypebot
|
})) as unknown as PublicTypebot
|
||||||
const fileUploadBlock = typebot.groups
|
const fileUploadBlock = typebot.groups
|
||||||
.flatMap((g) => g.blocks)
|
.flatMap((g) => g.blocks)
|
||||||
.find(byId(blockId))
|
.find(byId(blockId))
|
||||||
if (fileUploadBlock?.type !== InputBlockType.FILE) return badRequest(res)
|
if (fileUploadBlock?.type !== InputBlockType.FILE)
|
||||||
|
return badRequest(res, 'Not a file upload block')
|
||||||
const sizeLimit = fileUploadBlock.options.sizeLimit
|
const sizeLimit = fileUploadBlock.options.sizeLimit
|
||||||
? Math.min(fileUploadBlock.options.sizeLimit, 500)
|
? Math.min(fileUploadBlock.options.sizeLimit, 500)
|
||||||
: 10
|
: 10
|
||||||
|
@ -24,7 +24,7 @@ export const FileUploadForm = ({
|
|||||||
const { resultId } = useAnswers()
|
const { resultId } = useAnswers()
|
||||||
const [selectedFiles, setSelectedFiles] = useState<File[]>([])
|
const [selectedFiles, setSelectedFiles] = useState<File[]>([])
|
||||||
const [isUploading, setIsUploading] = useState(false)
|
const [isUploading, setIsUploading] = useState(false)
|
||||||
const [uploadProgressPercent, setUploadProgressPercent] = useState(20)
|
const [uploadProgressPercent, setUploadProgressPercent] = useState(10)
|
||||||
const [isDraggingOver, setIsDraggingOver] = useState(false)
|
const [isDraggingOver, setIsDraggingOver] = useState(false)
|
||||||
const [errorMessage, setErrorMessage] = useState<string>()
|
const [errorMessage, setErrorMessage] = useState<string>()
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ import { config, Endpoint, S3 } from 'aws-sdk'
|
|||||||
|
|
||||||
type GeneratePresignedUrlProps = {
|
type GeneratePresignedUrlProps = {
|
||||||
filePath: string
|
filePath: string
|
||||||
fileType: string
|
fileType?: string
|
||||||
sizeLimit?: number
|
sizeLimit?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user