Interface ProgressMonitor

  • Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    @FunctionalInterface
    public interface ProgressMonitor
    A ProgressMonitor is a functional interface which can be passed to unirest for the purposes of monitoring uploads and downloads. A common use case is for drawing progress bars. If an upload contains multiple files each one is called individually and the file name is provided. note that you will not receive a total for ALL files together at once. If you wanted this you can keep track of the total bytes of files you planned to upload and then have your ProgressMonitor aggregate the results.
    • Method Detail

      • accept

        void accept​(String field,
                    String fileName,
                    Long bytesWritten,
                    Long totalBytes)
        Accept stats about the current file upload chunk for a file.
        Parameters:
        field - the field name, or 'body' on non-multipart uploads/downloads
        fileName - the name of the file in question if available (InputStreams and byte arrays may not have file names)
        bytesWritten - the number of bytes that have been uploaded or downloaded so far
        totalBytes - the total bytes that will be uploaded or downloaded. On downloads this depends on the Content-Length header be returned On uploads this this may be an estimate if an InputStream was used