initial release
This commit is contained in:
29
bizmatch-server/src/file/file.service.ts
Normal file
29
bizmatch-server/src/file/file.service.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { fstat, readFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import path from 'path';
|
||||
import fs from 'fs-extra';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
@Injectable()
|
||||
export class FileService {
|
||||
private subscriptions: any;
|
||||
constructor() {
|
||||
this.loadSubscriptions();
|
||||
}
|
||||
private loadSubscriptions(): void {
|
||||
const filePath = join(__dirname,'..', 'assets', 'subscriptions.json');
|
||||
const rawData = readFileSync(filePath, 'utf8');
|
||||
this.subscriptions = JSON.parse(rawData);
|
||||
}
|
||||
getSubscriptions() {
|
||||
return this.subscriptions
|
||||
}
|
||||
async storeFile(file: Express.Multer.File,id: string){
|
||||
const suffix = file.mimetype.includes('png')?'png':'jpg'
|
||||
await fs.outputFile(`./public/profile_${id}`,file.buffer);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user