Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
@blazity/nest-file-fastify
Advanced tools
Readme
This library adds decorators for Nest.js to support fastify-multipart. The API is very similar to the official Nest.js Express file decorators.
NPM
$ npm install @blazity/nest-file-fastify fastify-multipart
Yarn
$ yarn add @blazity/nest-file-fastify fastify-multipart
import { FileInterceptor, UploadedFile, StorageFile } from '@blazity/nest-file-fastify';
@Post('upload')
@UseInterceptors(FileInterceptor('file'))
uploadFile(@UploadedFile() file: StorageFile) {
console.log(file);
}
FileInterceptor
arguments:
fieldname
: string - name of the field that holds a file
options
: optional object of type UploadOptions
import { FilesInterceptor, UploadedFiles, StorageFile } from '@blazity/nest-file-fastify';
@Post('upload')
@UseInterceptors(FilesInterceptor('files'))
uploadFile(@UploadedFiles() files: StorageFile[]) {
console.log(files);
}
FilesInterceptor
arguments:
fieldname
: string - name of the field that holds files
maxCount
: optional number - maximum number of files to accept
options
: optional object of type UploadOptions
import { FileFieldsInterceptor, UploadedFiles, StorageFile } from '@blazity/nest-file-fastify';
@Post('upload')
@UseInterceptors(FileFieldsInterceptor([
{ name: 'avatar', maxCount: 1 },
{ name: 'background', maxCount: 1 },
]))
uploadFile(@UploadedFiles() files: { avatar?: StorageFile[], background?: StorageFile[] }) {
console.log(files);
}
FileFieldsInterceptor
arguments:
uploadFields
: object of type UploadField
options
: optional object of type UploadOptions
import { AnyFilesInterceptor, UploadedFiles, StorageFile } from '@blazity/nest-file-fastify';
@Post('upload')
@UseInterceptors(AnyFilesInterceptor()
uploadFile(@UploadedFiles() files: StorageFile[]) {
console.log(files);
}
AnyFilesInterceptor
arguments:
options
: optional object of type UploadOptions
FAQs
fastify-multipart decorators for Nest.js
The npm package @blazity/nest-file-fastify receives a total of 4,136 weekly downloads. As such, @blazity/nest-file-fastify popularity was classified as popular.
We found that @blazity/nest-file-fastify demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.