fix wrong logic uploaded file

This commit is contained in:
2024-11-09 15:49:06 +07:00
parent 797018ed74
commit 2736547b84
6 changed files with 23 additions and 44 deletions

View File

@@ -1,4 +1,4 @@
import { Inject, Injectable } from '@nestjs/common'
import { Inject, Injectable, Logger } from '@nestjs/common'
import { ConfigService } from '@nestjs/config'
import { FileUpload } from 'graphql-upload/processRequest.js'
import { Client } from 'minio'
@@ -31,8 +31,8 @@ export class MinioService {
return { result, filename, mimetype, actualFileName }
}
async getFileUrl(id: string, category: string, presignUrl?: string) {
if (!id) {
async getFileUrl(fileName: string, category: string, presignUrl?: string) {
if (!fileName) {
return null
}
let url = null
@@ -47,14 +47,13 @@ export class MinioService {
url = await this.minioClient.presignedUrl(
'GET',
this.configService.get('BUCKET_NAME') ?? 'epess',
`${category}/${id}`,
`${category}/${fileName}`,
60 * 60 * 24 * 7,
)
} catch (error) {
console.log(error)
Logger.error(error, 'MinioService')
}
}
console.log(url)
return url
}