
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@newradius/nest-file-fastify
Advanced tools
这个库为Nest.js添加了装饰器,以支持@fastify/multipart。其 API 与官方的 Nest.js Express 文件装饰器非常相似。
NPM
$ npm install nest-file-fastify @fastify/multipart
Yarn
$ yarn add nest-file-fastify @fastify/multipart
pnpm
$ pnpm install nest-file-fastify @fastify/multipart
并在您的 Nest.js 应用程序中注册 multipart 插件
import fastyfyMultipart from '@fastify/multipart';
...
app.register(fastyfyMultipart);
FileInterceptor 参数:
fieldname: string - 包含文件的字段的名称
options: 可选的 UploadOptions 类型对象
import { FileInterceptor, UploadedFile, MemoryStorageFile } from 'nest-file-fastify';
@Post('upload')
@UseInterceptors(FileInterceptor('file'))
uploadFile(@UploadedFile() file: MemoryStorageFile) {
console.log(file);
}
FilesInterceptor 参数:
fieldname: string - 包含文件的字段的名称
maxCount: number - 可选的数字 - 接受的文件的最大数量
options: 可选的 UploadOptions 类型对象
import { FilesInterceptor, UploadedFiles, MemoryStorageFile } from 'nest-file-fastify';
@Post('upload')
@UseInterceptors(FilesInterceptor('files'))
uploadFile(@UploadedFiles() files: MemoryStorageFile[]) {
console.log(files);
}
FileFieldsInterceptor 参数:
uploadFields: 类型为 UploadField 的数组对象
options: 可选的 UploadOptions 类型对象
import { FileFieldsInterceptor, UploadedFiles, MemoryStorageFile } from 'nest-file-fastify';
@Post('upload')
@UseInterceptors(FileFieldsInterceptor([
{ name: 'avatar', maxCount: 1 },
{ name: 'background', maxCount: 1 },
]))
uploadFile(@UploadedFiles() files: { avatar?: MemoryStorageFile[], background?: MemoryStorageFile[] }) {
console.log(files);
}
AnyFilesInterceptor 参数:
options: 可选的 UploadOptions 类型对象import { AnyFilesInterceptor, UploadedFiles, MemoryStorageFile } from 'nest-file-fastify';
@Post('upload')
@UseInterceptors(AnyFilesInterceptor()
uploadFile(@UploadedFiles() files: MemoryStorageFile[]) {
console.log(files);
}
FAQs
@fastify/multipart decorators for Nest.js
We found that @newradius/nest-file-fastify demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.