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:
@@ -109,7 +109,14 @@ export default function UserDetailPage() {
|
||||
const docsWithUrls = await Promise.all(
|
||||
docs.map(async (doc) => {
|
||||
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 };
|
||||
} catch {
|
||||
return doc;
|
||||
|
||||
@@ -11,7 +11,8 @@ export interface AgentType {
|
||||
}
|
||||
|
||||
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;
|
||||
size: number;
|
||||
type: string;
|
||||
|
||||
Reference in New Issue
Block a user