Skip to content

Type value does not exist on MultipartFile when using onFile #574

Open
@mhamid3d

Description

@mhamid3d

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

5.2.1

Plugin version

9.0.3

Node.js version

23.7.0

Operating system

Windows

Operating system version (i.e. 20.04, 11.3, 10)

11

Description

When using onFile, the part does not have typings for value

So this code from the readme is not valid. As such I am providing this github repo as the reproducible example:

async function onFile(part) {
  const buff = await part.toBuffer()
  const decoded = Buffer.from(buff.toString(), 'base64').toString()
  part.value = decoded // set `part.value` to specify the request body value
}

fastify.register(require('@fastify/multipart'), { attachFieldsToBody: 'keyValues', onFile })

fastify.post('/upload/files', async function (req, reply) {
  const uploadValue = req.body.upload // access file as base64 string
  const fooValue = req.body.foo       // other fields
})

Link to code that reproduces the bug

https://github.com/fastify/fastify-multipart

Expected Behavior

Typings for value on MultipartFile

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions