Skip to content

Commit

Permalink
fix(bot): 🐛 Accept file upload without fileType
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Jul 1, 2022
1 parent 407cace commit 38a3ee7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>()

Expand Down
2 changes: 1 addition & 1 deletion packages/utils/src/api/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { config, Endpoint, S3 } from 'aws-sdk'

type GeneratePresignedUrlProps = {
filePath: string
fileType: string
fileType?: string
sizeLimit?: number
}

Expand Down

4 comments on commit 38a3ee7

@vercel
Copy link

@vercel vercel bot commented on 38a3ee7 Jul 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

viewer-v2-alpha – ./apps/viewer

am.nigerias.io
an.nigerias.io
bt.id8rs.com
apr.nigerias.io
bot.aws.bj
ar.nigerias.io
vhpage.cr8.ai
aso.nigerias.io
apo.nigerias.io
sat.cr8.ai
eventhub.com.au
bot.upfunnel.art
bot.piccinato.co
chat.sureb4.com
sakuranembro.it
games.klujo.com
clo.closeer.work
faqs.nigerias.io
feedback.ofx.one
stan.vselise.com
voicehelp.cr8.ai
bot.agfunnel.tech
ov1.wpwakanda.com
gentleman-shop.fr
app.chatforms.net
bot.maitempah.com
sell.applepie.pro
ov3.wpwakanda.com
admin.applepie.pro
ov2.wpwakanda.com
goalsettingbot.com
this-is-a-test.com
bot.eventhub.com.au
zap.techadviser.in
forms.webisharp.com
order.maitempah.com
typebot.stillio.com
chat.hayurihijab.com
bot.ansuraniphone.my
bot.cotemeuplano.com
get.freebotoffer.xyz
abutton.wpwakanda.com
bot.meuesocial.com.br
chat.missarkansas.org
bot.incusservices.com
cdd.searchcube.com.sg
bbutton.wpwakanda.com
apply.ansuraniphone.my
sbutton.wpwakanda.com
c23111azqw.nigerias.io
bbutton.wpwwakanda.com
felipewelington.com.br
form.searchcube.com.sg
info.clickasuransi.com
view.onlinebotdemo.xyz
kodawariab736.skeep.it
bot.upgradesolutions.eu
83242573.actualizar.xyz
gcase.barrettamario.it
mainmenu.diddancing.com
subfooter.wpwakanda.com
91181264.your-access.one
form.sergiolimajr.com.br
type.opaulovieira.com.br
hunterbot.saleshunter.ai
bot.cabinrentalagency.com
aibot.angrybranding.co.uk
boyfriend-breakup.riku.ai
type.dericsoncalari.com.br
piazzatorre.barrettamario.it
designguide.techyscouts.com
presente.empresarias.com.mx
onboarding.libertydreamcare.ie
bot.comercializadoraomicron.com
type.talitasouzamarques.com.br
personal-trainer.barrettamario.it
preagendamento.sergiolimajr.com.br
agendamento.sergiolimajr.com.br
bookings.littlepartymonkeys.com
viewer-v2-alpha-typebot-io.vercel.app
viewer-v2-alpha-git-main-typebot-io.vercel.app
studiotecnicoimmobiliaremerelli.it

@vercel
Copy link

@vercel vercel bot commented on 38a3ee7 Jul 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 38a3ee7 Jul 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

app.typebot.io
builder-v2-git-main-typebot-io.vercel.app
builder-v2-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 38a3ee7 Jul 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

docs – ./apps/docs

docs-git-main-typebot-io.vercel.app
docs.typebot.io
docs-typebot-io.vercel.app

Please sign in to comment.