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 typebotId = req.query.typebotId 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({
|
||||
where: { typebotId },
|
||||
})) as unknown as PublicTypebot
|
||||
const fileUploadBlock = typebot.groups
|
||||
.flatMap((g) => g.blocks)
|
||||
.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
|
||||
? Math.min(fileUploadBlock.options.sizeLimit, 500)
|
||||
: 10
|
||||
|
@ -24,7 +24,7 @@ export const FileUploadForm = ({
|
||||
const { resultId } = useAnswers()
|
||||
const [selectedFiles, setSelectedFiles] = useState<File[]>([])
|
||||
const [isUploading, setIsUploading] = useState(false)
|
||||
const [uploadProgressPercent, setUploadProgressPercent] = useState(20)
|
||||
const [uploadProgressPercent, setUploadProgressPercent] = useState(10)
|
||||
const [isDraggingOver, setIsDraggingOver] = useState(false)
|
||||
const [errorMessage, setErrorMessage] = useState<string>()
|
||||
|
||||
|
@ -2,7 +2,7 @@ import { config, Endpoint, S3 } from 'aws-sdk'
|
||||
|
||||
type GeneratePresignedUrlProps = {
|
||||
filePath: string
|
||||
fileType: string
|
||||
fileType?: string
|
||||
sizeLimit?: number
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user