use of org.kie.workbench.common.forms.jbpm.server.service.impl.documents.DocumentUploadSession in project kie-wb-common by kiegroup.
the class FormsDocumentServlet method doPost.
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
Map<String, Object> response = new HashMap<>();
try {
FileItem fileItem = getFileItem(req);
String id = UUID.randomUUID().toString();
String content = Base64.getEncoder().encodeToString(fileItem.get());
DocumentUploadChunk chunk = new DocumentUploadChunk(id, fileItem.getName(), 0, 1, content);
DocumentUploadSession session = new DocumentUploadSession(chunk.getDocumentId(), chunk.getDocumentName(), chunk.getMaxChunks());
session.add(chunk);
storage.uploadContentChunk(chunk);
session.setState(DocumentUploadSession.State.MERGING);
storage.merge(session);
DocumentData data = new DocumentData(id, fileItem.getName(), fileItem.getSize(), "", System.currentTimeMillis());
response.put("document", data);
} catch (Exception e) {
response.put("error", "error");
} finally {
writeResponse(resp, response);
}
}
Aggregations