abs-nestjs-file-service
v0.0.1
Published
`FileService` is a custom file service that can be used in a NestJS to log your http request logs
Readme
FileService Documentation
FileService is a custom file service that can be used in a NestJS to log your http request logs
Installation
To install the necessary dependencies, run:
npm install abs-nestjs-file-serviceUsage with NestJS
- Set API_URL variable in .env file
API_URL="http://localhost:3000/public"
- Import the FileService into your module:
import { Module } from '@nestjs/common';
import { FileService } from 'abs-nestjs-file-service';
@Module({
providers: [FileService],
exports: [FileService],
})
export class AppModule {}
- Inject the FileService into your service or controller:
import { Injectable } from '@nestjs/common';
import { FileService } from 'abs-nestjs-file-service';
@Injectable()
export class SomeService {
constructor(private readonly fileService: FileService) {}
async someMethod() {
const folderPath = '/image';
const filename = 'some-image.png';
const fileUrl = this.fileService.getFileUrl(folderPath, filename);
console.log(fileUrl);
const basePath = '/public';
const filePath = this.fileService.getFilePath(basePath, folderPath, filename);
console.log(filePath);
await this.fileService.delete(filePath);
}
}
