npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@hassan23el/nestjs-file-storage

v1.2.9

Published

NestJS file storage and upload module

Readme

nestjs-file-storage/ ├─ package.json ├─ tsconfig.json ├─ .gitignore ├─ README.md └─ src/ ├─ index.ts ├─ service/file.service.ts ├─ interceptors/file-storage.interceptor.ts ├─ decorators/allowed-files.decorator.ts └─ upload.module.ts


nestjs-file-storage

NestJS File Storage Package – A complete solution for handling file uploads, replacements, moves, bulk operations, and deletions in NestJS applications.

Features

  • Save single or multiple files
  • Replace single or multiple files
  • Move single or multiple files
  • Bulk delete files
  • Delete entire folders
  • File validation (size and type)
  • NestJS decorator & interceptor integration
  • Global UploadModule for easy access
  • Ready for scoped npm package

Installation

npm install @hassan23el/nestjs-file-storage

Setup

Import Global Module

import { Module } from '@nestjs/common';
import { UploadModule } from '@hassan23el/nestjs-file-storage';

@Module({
  imports: [UploadModule], // Import once in root module
})
export class AppModule {}
  • With @Global() applied, FileService is available everywhere without importing UploadModule in other modules.

Import Service Directly (Optional)

import { Module } from '@nestjs/common';
import { FileService } from '@hassan23el/nestjs-file-storage';

@Module({
  providers: [FileService],
  exports: [FileService],
})
export class SomeModule {}

Usage

Upload files with decorator

import { Controller, Post, Body, Param, UploadedFiles } from '@nestjs/common';
import { AllowedFiles, FileService } from '@hassan23el/nestjs-file-storage';

@Controller('ads')
export class AdsController {
  constructor(private readonly fileService: FileService) {}

  @Post(':id/images')
  @AllowedFiles({ maxFiles: 5, maxSizeMB: 10 })
  async uploadAdImages(
    @Param('id') id: string,
    @Body() dto,
  ) {
    savedFiles = dto.file_fileds    
    return { files: savedFiles };
  }
}

Replace existing files

const oldPaths = ['ads/1/old1.jpg', 'ads/1/old2.jpg'];
const newFiles = dto.images; // from @UploadedFiles()
const newPaths = await this.fileService.replaceFiles(oldPaths, newFiles, `ads/${id}`);

Move files

const moved = await this.fileService.moveFiles(['ads/1/file1.jpg'], 'archived/ads');

Delete files or folders

await this.fileService.deleteFile('ads/1/file1.jpg');
await this.fileService.deleteFiles(['ads/1/file2.jpg', 'ads/1/file3.jpg']);
await this.fileService.deleteFolder('ads/1');

Validation

Use @AllowedFiles decorator for:

  • Maximum number of files
  • Maximum file size (MB)
  • Allowed file types (default: images + PDF)
@AllowedFiles({ maxFiles: 5, maxSizeMB: 10, regex: /\/(jpg|jpeg|png|gif|pdf)$/ })

Directory Structure

uploads/
└─ temp/             # default temporary uploads
└─ ads/:id/          # custom entity folders

Git Ignore Recommendations

node_modules/
dist/
uploads/
.env
.npmrc

Exports

import {
  FileService,
  FileStorageInterceptor,
  AllowedFiles,
  AllowedFilesOptions,
  UploadModule
} from '@hassan23el/nestjs-file-storage';
  • FileService – core file operations
  • FileStorageInterceptor – NestJS interceptor
  • AllowedFiles – decorator for validation
  • AllowedFilesOptions – interface for options
  • UploadModule – global module providing FileService

License

MIT