feat: Update document download logic to use id as a fallback for the S3 key and refine the VerificationDocument interface.

This commit is contained in:
pradeepkumar
2026-01-29 00:02:45 +05:30
parent 334a55f0a0
commit f30769d73a
2 changed files with 10 additions and 2 deletions

View File

@@ -109,7 +109,14 @@ export default function UserDetailPage() {
const docsWithUrls = await Promise.all( const docsWithUrls = await Promise.all(
docs.map(async (doc) => { docs.map(async (doc) => {
try { try {
const url = await uploadService.getPresignedDownloadUrl(doc.key); // The S3 key is stored in 'id' field from the upload service
// or in 'key' field if explicitly set. Fall back to id if key is missing.
const fileKey = doc.key || doc.id;
if (!fileKey || fileKey.startsWith('http')) {
// If no key or already a URL, return document as-is
return doc;
}
const url = await uploadService.getPresignedDownloadUrl(fileKey);
return { ...doc, url }; return { ...doc, url };
} catch { } catch {
return doc; return doc;

View File

@@ -11,7 +11,8 @@ export interface AgentType {
} }
export interface VerificationDocument { export interface VerificationDocument {
key: string; id?: string; // S3 key is stored in id field from upload service
key?: string; // Alternative S3 key field
name: string; name: string;
size: number; size: number;
type: string; type: string;