@Override public void streamingFinished(StreamVariable.StreamingEndEvent event) { String fileName = event.getFileName(); int index = fileName.lastIndexOf("."); if (index > 0) { String fileExt = fileName.substring(index + 1, fileName.length()); fileName = MobileAttachmentUtils.ATTACHMENT_NAME_PREFIX + System.currentTimeMillis() + "." + fileExt; } if (!indicators.isEmpty()) { statusWrapper.replaceComponent(indicators.remove(0), createAttachmentRow(fileName)); } File file = receiver.getFile(); receiveFile(file, fileName, event.getMimeType(), event.getBytesReceived()); receiver.setValue(null); }
@Override public void streamingFailed(StreamVariable.StreamingErrorEvent event) { if (!indicators.isEmpty()) { Label uploadResult = new Label("Upload failed! File: " + event.getFileName()); uploadResult.setStyleName("upload-status"); statusWrapper.replaceComponent(indicators.remove(0), uploadResult); } }
@Override public void onProgress(StreamVariable.StreamingProgressEvent event) { long readBytes = event.getBytesReceived(); long contentLength = event.getContentLength(); float f = (float) readBytes / (float) contentLength; indicators.get(0).setValue(f); }
private StreamVariable createStreamVariable(final Html5File file, final SoftwareModule selectedSw) { return new UploadHandler(file.getFileName(), file.getFileSize(), UploadLayout.this, multipartConfigElement.getMaxFileSize(), null, file.getType(), selectedSw, softwareModuleManagement); }
@Override public void streamingStarted(StreamVariable.StreamingStartEvent event) { }