@Override protected byte[] doConvert(Object value, Formatter<?> formatter) throws Exception { if (value instanceof byte[]) { return (byte[]) value; } if (value instanceof UploadedFile) { return ((UploadedFile) value).getData(); } if (value instanceof UploadedFile[]) { return ((UploadedFile[]) value)[0].getData(); } return null; }
@Override public String toString() { return "file=\'" + this.filename + "\', size=" + this.getSize() + ", creationDate = " + creationDate + ", modificationDate = " + modificationDate; } }
@Override public void populate(DataTransferBlock transferBlock) throws UnifyException { if (transferBlock != null) { DataTransferBlock nextBlock = transferBlock.getChildBlock(); Object value = nextBlock.getValue(); // Attach FileAttachmentsInfo fileAttachmentsInfo = getAttachmentsInfo(); fileAttachmentsInfo.setSelectedIndex(nextBlock.getItemIndex()); FileAttachmentInfo fileAttachmentInfo = (FileAttachmentInfo) fileAttachmentsInfo.getSelectedAttachmentInfo(); UploadedFile uploadedFile = ((UploadedFile[]) value)[0]; fileAttachmentInfo.setFilename(uploadedFile.getFilename()); fileAttachmentInfo.setAttachment(uploadedFile.getData()); fileAttachmentsInfo.attach(); String handler = getUplAttribute(String.class, "handler"); if (handler != null) { FileAttachmentHandler fileAttachmentHandler = (FileAttachmentHandler) getComponent(handler); fileAttachmentHandler.handleAttach(fileAttachmentsInfo.getParentId(), fileAttachmentInfo); fileAttachmentInfo.setAttachment(null); } } }
if (contentDisposition.isFileName()) { UploadedFile frmFile = new UploadedFile(contentDisposition.getFileName(), contentDisposition.getCreationDate(), contentDisposition.getModificationDate(), IOUtils.readAll(part.getInputStream())); List<UploadedFile> list = uploadedFileMap.get(name);
@Override public void populate(DataTransferBlock transferBlock) throws UnifyException { super.populate(transferBlock); if (uploadedFile != null && uploadedFile.length > 0) { setValue(uploadedFile[0].getData()); } uploadedFile = null; }