Account
Earned badges
Achievement: Latest Unlocked
Replies
Preferences
Topics Started
Topic Started
Replies Created
Reply to: Error during downloading the attachment
Tuesday, January 14, 2020 at 08:47pmReply to: Error during downloading the attachment
Wednesday, January 15, 2020 at 08:35pmReply to: Error during downloading the attachment
Thursday, January 23, 2020 at 03:06amHello Duo,
The JSON Payload I receive from OneSpan, when it fails, looks like this:
JSON Payload:
{"name":"PACKAGE_ATTACHMENT","sessionUser":"customer","packageId":"hpHHaUoNRWlgACRIpRmKcKWIQ_E=","message":"PIECE D'IDENTITE","documentId":""}
Could it be that it fails because the documentId is coming as empty?
Best Regards,
MIchail
Reply to: Hi Michail Below is a…
Monday, January 27, 2020 at 02:40amHello Duo,
Here is the code:
String attachmentType = trimToEmpty(notification.getMessage());
String attachmentId = null;
ESLAttachment attachmentDoc = null;
Signer signer = eslClient.getPackageService().getSigner(new PackageId(prospectESignTransaction.getPackageId()), "customer");
AttachmentRequirement attachment = signer.getAttachmentRequirement(attachmentType);
attachmentId = null != attachment ? attachment.getId() : null;
RestClient client = new RestClient(prospectESignTransaction.getApiKey());
String path = MinConstant.ESL_API_URL + "/packages/" + prospectESignTransaction.getPackageId()
+ "/attachment/" + attachmentId;
Map<String, Object> responseMap = client.get(path, "application/octet-stream");
if (null != responseMap && null != responseMap.get("responseBody")) {
String attachmentName = "attachment.pdf";
CloseableHttpResponse response = (CloseableHttpResponse) responseMap.get("response");
byte[] byteArray = (byte[]) responseMap.get("responseBody");
HeaderElement[] headerElements = response.getFirstHeader("Content-Disposition").getElements();
if (null != headerElements && headerElements.length > 0) {
for (int i=0; i<headerElements.length; i++) {
if (null != headerElements[i].getParameterByName("filename")) {
attachmentName = headerElements[i].getParameterByName("filename").getValue();
break;
}
}
}
File dir = new File(tempFolder);
if (!dir.exists()) {
dir.mkdir();
}
List<ESLAttachment> eslAttachments = eslDAO.getAttachmentsForPlatform(prospectESignTransaction.getPlatformId());
if (CollectionUtils.isNotEmpty(eslAttachments)) {
for (ESLAttachment eslAttachment : eslAttachments) {
if (equalsIgnoreCase(attachmentType, eslAttachment.getName())) {
attachmentDoc = eslAttachment;
break;
}
}
}
attachmentName = Normalizer.normalize(attachmentName, Normalizer.Form.NFC).replaceAll("[^\\p{ASCII}]", "");
Files.saveTo(byteArray, tempFolder + File.separator + attachmentName);
FileUtils.deleteQuietly(dir);
}
}
}
Best Regards,
Michail
Reply to: Hi Michail, I tried your…
Tuesday, January 28, 2020 at 03:01amHello Duo,
The error is not happening always. In most of the cases it works fine.
4-5 times per day, it fails.
Regards,
Michail