mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-11-26 16:44:54 +00:00
feat: upload document to oci bucket
This commit is contained in:
24
src/document/services/document.service.ts
Normal file
24
src/document/services/document.service.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import { Injectable, NotFoundException } from '@nestjs/common';
|
||||
import { UploadDocumentRequestDto } from '../dtos/request';
|
||||
import { DocumentRepository } from '../repositories';
|
||||
import { OciService } from './oci.service';
|
||||
|
||||
@Injectable()
|
||||
export class DocumentService {
|
||||
constructor(private readonly ociService: OciService, private readonly documentRepository: DocumentRepository) {}
|
||||
async createDocument(file: Express.Multer.File, uploadedDocumentRequest: UploadDocumentRequestDto) {
|
||||
const uploadedFile = await this.ociService.uploadFile(file, uploadedDocumentRequest);
|
||||
console.log('test');
|
||||
return this.documentRepository.createDocument(uploadedFile);
|
||||
}
|
||||
|
||||
async findDocumentById(documentId: string) {
|
||||
const document = await this.documentRepository.findDocumentById(documentId);
|
||||
|
||||
if (!document) {
|
||||
throw new NotFoundException('DOCUMENT.NOT_FOUND');
|
||||
}
|
||||
|
||||
return document;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user