made the presigned url middleware
This commit is contained in:
@@ -10,6 +10,8 @@ import { hostCompanyDetailsSchema } from '@/common/utils/validation/host/hostCom
|
||||
import { HOST_STATUS_DISPLAY, HOST_STATUS_INTERNAL, STEPPER } from '@/common/utils/constants/host.constant';
|
||||
import { MINGLAR_STATUS_DISPLAY, MINGLAR_STATUS_INTERNAL } from '@/common/utils/constants/minglar.constant';
|
||||
import { ROLE } from '@/common/utils/constants/common.constant';
|
||||
import { getPresignedUrl } from '@/common/middlewares/aws/getPreSignedUrl';
|
||||
import config from '@/config/config';
|
||||
|
||||
type HostCompanyDetailsInput = z.infer<typeof hostCompanyDetailsSchema>;
|
||||
|
||||
@@ -58,6 +60,23 @@ export class HostService {
|
||||
return { stepper: STEPPER.NOT_SUBMITTED } as any;
|
||||
}
|
||||
|
||||
if (host.HostDocuments?.length) {
|
||||
const bucket = config.aws.bucketName;
|
||||
|
||||
for (const doc of host.HostDocuments) {
|
||||
if (doc.filePath) {
|
||||
const filePath = doc.filePath;
|
||||
|
||||
// If full URL is saved, extract only key
|
||||
const key = filePath.startsWith("http")
|
||||
? filePath.split(".com/")[1]
|
||||
: filePath;
|
||||
|
||||
(doc as any).presignedUrl = await getPresignedUrl(bucket, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return host;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user