#@fastify/multipart

1 messages Β· Page 1 of 1 (latest)

sand locust
#

Does anyone have problems with @fastify/multipart, I'm trying to get the file that is sent but it returns undefined

#

This plugin is registred correctly

vestal inlet
#

is Content-Type being set?

#
  // process a single file
  // also, consider that if you allow to upload multiple files
  // you must consume all files otherwise the promise will never fulfill
  const data = await req.file()
#

it looks like you're sending 2 files, correct?

#

@sand locust

sand locust
#

One file.

vestal inlet
sand locust
#

The first only text

vestal inlet
#

I've never used that app so idk, it might be caused by the same thing though

#

try it if you haven't

sand locust
vestal inlet
#

I think it's the same problem

#

The fastify page doesn't distinguish between files and just text

sand locust
#

If im using this

#

returns true

#

Function from @fastify/multipart

rotund hatch
sand locust
rotund hatch
sand locust
#

Im don`t speak english :(

rotund hatch
#

ok okk

sand locust
#

Waiting...

#

My network is very bad

rotund hatch
#

good

sand locust
#

Ok.

#

Send me information

rotund hatch
#

show me test

#

try files()

#

okey show me your insomnia config and slow πŸ™‚ move haha its hard to follow

sand locust
#

This?

rotund hatch
#

ok

#

go to your code, and do a console.log(req)

sand locust
#

Ok

rotund hatch
#

ok

#

try to do this

#

@sand locust

#

also use

bun --watch yourfile.ts

#

to not rerun server each time

#

it should be in your package.json

#

u dont need to stop server and run it i think

#

so yeah

sand locust
#

yes , sorry

rotund hatch
#

file type is not allowed

sand locust
#

yeah.

rotund hatch
#
const files = await req.files();
console.log(files)
#

super weird

sand locust
#

I tried open issue in @fastify/multipart

rotund hatch
#

can you try to create a test file

test.ts

const fastify = require('fastify')()

fastify.register(require('@fastify/multipart'))

fastify.post('/upload', async function (req, reply) {
  const data = await req.file()

 console.log(data)

  reply.send()
})

fastify.listen({ port: 3000 }, err => {
  if (err) throw err
  console.log(`server listening on ${fastify.server.address().port}`)
})
#

and run it

#

try with node run

sand locust
#

its worked.

rotund hatch
#

yeah weird

sand locust
#

very

rotund hatch
#

dont use then fastify πŸ™‚

sand locust
#

Sad

rotund hatch
#

try another package or bun native http api

sand locust
#

Ok thanks.

rotund hatch
#

πŸ˜‰ ywlc

sand locust
#

@rotund hatch How to get file info using Bun Server?

#

Got it