2
0

fix(bot): 🐛 Accept file upload without fileType

This commit is contained in:
Baptiste Arnaud
2022-07-01 17:52:58 +02:00
parent 407cace752
commit 38a3ee7010
3 changed files with 5 additions and 4 deletions

View File

@ -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

View File

@ -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>()

View File

@ -2,7 +2,7 @@ import { config, Endpoint, S3 } from 'aws-sdk'
type GeneratePresignedUrlProps = {
filePath: string
fileType: string
fileType?: string
sizeLimit?: number
}