sending the profile image in presigned url
This commit is contained in:
@@ -125,6 +125,13 @@ export class HostService {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (host.user) {
|
||||
const key = host.user.profileImage.startsWith("http")
|
||||
? host.user.profileImage.split(".com/")[1]
|
||||
: host.user.profileImage;
|
||||
|
||||
host.user.profileImage = await getPresignedUrl(bucket, key);
|
||||
}
|
||||
|
||||
if (host.logoPath) {
|
||||
const key = host.logoPath.startsWith('http')
|
||||
|
||||
@@ -15,22 +15,22 @@ export const handler = safeHandler(async (
|
||||
): Promise<APIGatewayProxyResult> => {
|
||||
// Get host ID from path parameters
|
||||
const token = event.headers['x-auth-token'] || event.headers['X-Auth-Token']
|
||||
if(!token) {
|
||||
if (!token) {
|
||||
throw new ApiError(400, 'This is a protected route. Please provide a valid token.');
|
||||
}
|
||||
|
||||
await verifyMinglarAdminToken(token);
|
||||
|
||||
const host_xid = event.pathParameters?.host_xid;
|
||||
if (!host_xid) {
|
||||
throw new ApiError(
|
||||
400,
|
||||
'Host ID is required in path parameters.',
|
||||
);
|
||||
}
|
||||
if (!host_xid) {
|
||||
throw new ApiError(
|
||||
400,
|
||||
'Host ID is required in path parameters.',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
const hostDetails = await minglarService.getHostDetailsById(host_xid);
|
||||
const hostDetails = await minglarService.getHostDetailsById(Number(host_xid));
|
||||
|
||||
if (!hostDetails) {
|
||||
throw new ApiError(404, 'Host not found');
|
||||
|
||||
@@ -1389,6 +1389,14 @@ export class MinglarService {
|
||||
host.logoPath = await getPresignedUrl(bucket, key);
|
||||
}
|
||||
|
||||
if (host.user) {
|
||||
const key = host.user.profileImage.startsWith("http")
|
||||
? host.user.profileImage.split(".com/")[1]
|
||||
: host.user.profileImage;
|
||||
|
||||
host.user.profileImage = await getPresignedUrl(bucket, key);
|
||||
}
|
||||
|
||||
if (host.hostParent?.length) {
|
||||
const parent = host.hostParent[0]; // since you allow only 1 parent
|
||||
|
||||
|
||||
Reference in New Issue
Block a user