ams-ssk v1.0.5
AMS (Asset Management System) Library
A NestJS library for file management and asset operations that can be integrated into any NestJS application.
Features
- File and folder management (create, read, update, delete)
- File uploads and downloads
- File metadata operations
- JSON file operations with path-based queries
- File thumbnails and previews
- Folder archiving
- File search capabilities
- File sharing links
Installation
npm install ams
Usage
Basic Usage
In your NestJS application, import the FileModule
into your AppModule:
import { Module } from '@nestjs/common';
import { FileModule } from 'ams';
@Module({
imports: [
FileModule.register(), // Use default configuration
],
})
export class AppModule {}
Configuration Options
You can customize the module's behavior by using the forRoot()
method:
import { Module } from '@nestjs/common';
import { FileModule } from 'ams';
@Module({
imports: [
FileModule.forRoot({
storagePath: './custom-uploads',
maxFileSize: 10 * 1024 * 1024, // 10MB
allowedFileTypes: ['image/jpeg', 'image/png', 'application/pdf'],
}),
],
})
export class AppModule {}
Using as a Global Module
You can also make the module available globally:
import { Module } from '@nestjs/common';
import { FileModule } from 'ams';
@Module({
imports: [
FileModule.forRootGlobal({
storagePath: './global-uploads',
}),
],
})
export class AppModule {}
Using the FileService
Once you've imported the module, you can inject the FileService into your controllers or services:
import { Controller, Get, Inject } from '@nestjs/common';
import { FileService } from 'ams';
@Controller('my-files')
export class MyFilesController {
constructor(private readonly fileService: FileService) {}
@Get('folders')
async listAllFolders() {
return this.fileService.listFolders();
}
@Get('recent')
async getRecentFiles() {
return this.fileService.getRecentFiles();
}
}
Available Methods
The FileService provides many methods for file and folder operations:
listFolders()
: List all foldersgetFolderDetails(folder, page, limit)
: Get paginated folder contentscreateFolder(folderName)
: Create a new folderdeleteFolder(folder)
: Delete an empty folderuploadFiles(folder, files, filenameQuery)
: Upload files to a folderdownloadFile(folder, filename, res)
: Download a specific filegetFileMetadata(folder, filename)
: Get metadata for a filemoveFile(folder, filename, body)
: Move or rename a filecopyFile(folder, filename, body)
: Copy a filedeleteFile(folder, filename)
: Delete a filegetJsonFile(folder, filename)
: Get content of a JSON filequeryJsonFile(folder, filename, query)
: Query a JSON file using path notation- ... and many more
API Documentation
After installing and configuring the module, you can access the Swagger documentation for the API endpoints at:
http://your-app-url/api-docs
License
MIT
Resources
Check out a few resources that may come in handy when working with NestJS:
- Visit the NestJS Documentation to learn more about the framework.
- For questions and support, please visit our Discord channel.
- To dive deeper and get more hands-on experience, check out our official video courses.
- Deploy your application to AWS with the help of NestJS Mau in just a few clicks.
- Visualize your application graph and interact with the NestJS application in real-time using NestJS Devtools.
- Need help with your project (part-time to full-time)? Check out our official enterprise support.
- To stay in the loop and get updates, follow us on X and LinkedIn.
- Looking for a job, or have a job to offer? Check out our official Jobs board.
Support
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.
Stay in touch
- Author - Kamil Myśliwiec
- Website - https://nestjs.com
- Twitter - @nestframework
License
Nest is MIT licensed.