handle resume file upload and url
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user