fix: preserve qualification file names across uploads
This commit is contained in:
@@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@Service
|
||||
public class QualificationPackageService {
|
||||
@@ -45,9 +46,10 @@ public class QualificationPackageService {
|
||||
String legalPersonIdDocumentUrl = storedLegalPersonId == null ? null : storedLegalPersonId.documentUrl();
|
||||
|
||||
var request = new IamQualificationClient.RequiredPackageRequest(
|
||||
tenantId, normalizedCreditCode, storedBusinessLicense.documentUrl(), businessLicense.getOriginalFilename(),
|
||||
tenantId, normalizedCreditCode, storedBusinessLicense.documentUrl(),
|
||||
originalFileName(businessLicense, storedBusinessLicense, "business-license"),
|
||||
businessLicenseValidTo, replaceBusinessLicense, legalPersonIdDocumentUrl,
|
||||
legalPersonId == null ? null : legalPersonId.getOriginalFilename(),
|
||||
legalPersonId == null ? null : originalFileName(legalPersonId, storedLegalPersonId, "legal-person-id"),
|
||||
legalPersonIdValidTo, replaceLegalPersonId);
|
||||
try {
|
||||
var response = platform
|
||||
@@ -87,6 +89,13 @@ public class QualificationPackageService {
|
||||
if (storedFile != null) storage.delete(storedFile);
|
||||
}
|
||||
|
||||
private String originalFileName(MultipartFile file, LocalQualificationStorage.StoredFile stored, String fallback) {
|
||||
String original = file.getOriginalFilename();
|
||||
if (StringUtils.hasText(original)) return original;
|
||||
String storedName = stored == null ? null : stored.fileName();
|
||||
return StringUtils.hasText(storedName) ? storedName : fallback;
|
||||
}
|
||||
|
||||
public record PackageUploadResult(Long businessLicenseQualificationId,
|
||||
Long legalPersonIdQualificationId,
|
||||
String tenantStatus,
|
||||
|
||||
Reference in New Issue
Block a user