handle resume file upload and url

This commit is contained in:
2024-10-15 01:18:39 +07:00
parent 5a5a53c0c9
commit dc81f6eaa8
3 changed files with 143 additions and 5 deletions

View File

@@ -3,6 +3,7 @@ import { ConfigService } from '@nestjs/config';
import { FileUpload } from 'graphql-upload/processRequest.js';
import { Client } from 'minio';
import { MINIO_CONNECTION } from 'nestjs-minio';
import { v4 as uuidv4 } from 'uuid';
@Injectable()
export class MinioService {
constructor(
@@ -11,7 +12,8 @@ export class MinioService {
) {}
async uploadFile(file: FileUpload, category: string) {
const { filename, mimetype, createReadStream, encoding } = await file;
const { mimetype, createReadStream, encoding } = await file;
const filename = this.fileName();
const Name = `${category}/${filename}`;
const fileBuffer = createReadStream();
@@ -44,4 +46,10 @@ export class MinioService {
fileName,
);
}
//
fileName() {
// generate a unique file name using uuid
return uuidv4();
}
}