import { Injectable } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';

@Injectable()
export class FilesService {
  constructor(private configService: ConfigService) {}

  async saveFileInfo(file: Express.Multer.File) {
    return {
      filename: file.filename,
      originalname: file.originalname,
      size: file.size,
      mimetype: file.mimetype,
      url: `/api/uploads/${file.filename}`,
    };
  }

  async saveMultipleFilesInfo(files: Express.Multer.File[]) {
    return Promise.all(files.map((file) => this.saveFileInfo(file)));
  }
}
