/** * @return estimate of the remaining number of milliseconds */ public long getRemainingMilliseconds() { int percentageComplete = getPercentageComplete(); long totalTime = ((getElapsedSeconds() * 100) / Math.max(percentageComplete, 1)); long remainingTime = (totalTime - getElapsedSeconds()); return remainingTime * 1000; // convert seconds to milliseconds and return }
/** * @return seconds elapsed since upload started */ public long getElapsedSeconds() { return getElapsedMilliseconds() / 1000L; }
/** * @param attributes * @return status string with progress data that will feed the progressbar.js variables on * browser to update the progress bar */ private String getStatus(final Attributes attributes) { final String upload = attributes.getParameters().get(UPLOAD_PARAMETER).toString(); final HttpServletRequest req = (HttpServletRequest)attributes.getRequest() .getContainerRequest(); UploadInfo info = MultipartServletWebRequestImpl.getUploadInfo(req, upload); String status; if ((info == null) || (info.getTotalBytes() < 1)) { status = "100|"; } else { status = info.getPercentageComplete() + "|" + new StringResourceModel(RESOURCE_STATUS, (Component)null, Model.of(info)).getString(); } return status; }
/** * @return estimate of the remaining time in a human readable string */ public String getRemainingTimeString() { return Duration.milliseconds(getRemainingMilliseconds()) .toString(Session.get().getLocale()); }
/** * Upload start callback * * @param totalBytes */ protected void onUploadStarted(int totalBytes) { UploadInfo info = new UploadInfo(totalBytes); setUploadInfo(getContainerRequest(), upload, info); }
/** * @return transfer rate in bits per second */ public long getTransferRateBPS() { return bytesUploaded / Math.max(getElapsedSeconds(), 1); }
/** * @return transfer rate in a human readable string */ public String getTransferRateString() { return Bytes.bytes(getTransferRateBPS()).toString(Session.get().getLocale()) + "/s"; }
/** * @param attributes * @return status string with progress data that will feed the progressbar.js variables on * browser to update the progress bar */ private String getStatus(final Attributes attributes) { final String upload = attributes.getParameters().get(UPLOAD_PARAMETER).toString(); final HttpServletRequest req = (HttpServletRequest)attributes.getRequest() .getContainerRequest(); UploadInfo info = MultipartServletWebRequestImpl.getUploadInfo(req, upload); String status; if ((info == null) || (info.getTotalBytes() < 1)) { status = "100|"; } else { status = info.getPercentageComplete() + "|" + new StringResourceModel(RESOURCE_STATUS, (Component)null, Model.of(info)).getString(); } return status; }
/** * @return estimate of the remaining time in a human readable string */ public String getRemainingTimeString() { return Duration.milliseconds(getRemainingMilliseconds()) .toString(Session.get().getLocale()); }
/** * Upload start callback * * @param totalBytes */ protected void onUploadStarted(int totalBytes) { UploadInfo info = new UploadInfo(totalBytes); setUploadInfo(getContainerRequest(), upload, info); }
/** * @return transfer rate in bits per second */ public long getTransferRateBPS() { return bytesUploaded / Math.max(getElapsedSeconds(), 1); }
/** * @return transfer rate in a human readable string */ public String getTransferRateString() { return Bytes.bytes(getTransferRateBPS()).toString(Session.get().getLocale()) + "/s"; }
/** * @param attributes * @return status string with progress data that will feed the progressbar.js variables on * browser to update the progress bar */ private String getStatus(final Attributes attributes) { final String upload = attributes.getParameters().get(UPLOAD_PARAMETER).toString(); final HttpServletRequest req = (HttpServletRequest)attributes.getRequest() .getContainerRequest(); UploadInfo info = MultipartServletWebRequestImpl.getUploadInfo(req, upload); String status; if ((info == null) || (info.getTotalBytes() < 1)) { status = "100|"; } else { status = info.getPercentageComplete() + "|" + new StringResourceModel(RESOURCE_STATUS, (Component)null, Model.of(info)).getString(); } return status; }
/** * @return estimate of the remaining number of milliseconds */ public long getRemainingMilliseconds() { int percentageComplete = getPercentageComplete(); long totalTime = ((getElapsedSeconds() * 100) / Math.max(percentageComplete, 1)); long remainingTime = (totalTime - getElapsedSeconds()); return remainingTime * 1000; // convert seconds to milliseconds and return }
/** * @return seconds elapsed since upload started */ public long getElapsedSeconds() { return getElapsedMilliseconds() / 1000L; }