import { Injectable } from '@nestjs/common';
import { UpdateFileDto } from './dto/update-file.dto';
import { AuthPayload } from 'src/auth/decorators/auth.payload';
import { PrismaService } from 'src/prisma/prisma.service';
import { createReadStream } from 'fs';
import { join } from 'path';

@Injectable()
export class FilesService {
  constructor(private prisma: PrismaService) {}

  create(file: Express.Multer.File, tenant: AuthPayload) {
    // save file id
    // this.prisma.

    return file.filename;
  }

  getFile(path: string, id: string) {
    const file = createReadStream(join(process.cwd(), path, id));
    return file;
  }

  update(id: number, updateFileDto: UpdateFileDto) {
    return `This action updates a #${id} file`;
  }

  remove(id: number) {
    return `This action removes a #${id} file`;
  }
}
