fastify / fastify/fastify-multipart
Type value does not exist on MultipartFile when using onFile
- Dominant language
- JavaScript
- Stars
- 539
- Forks
- 126
- PR merge metrics
- No merged PRs in 30d
Description
### Prerequisites
- [x] I have written a descriptive issue title
- [x] 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:
```js
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`
Contributor guide
Assessment
This issue has not been assessed yet.