File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ ------
2
+ Async Http Client - Uploading file: Progress Listener
3
+ ------
4
+ Jeanfrancois Arcand
5
+ ------
6
+ 2012
7
+
8
+ Uploading file: Progress Listener
9
+
10
+ When uploading bytes, an application might need to take some action depending on where the upload status is.
11
+
12
+ The AsyncHttpClient library support a special <<<AsyncHandler>>> called <<<ProgressAsyncHandler>>> that can be used to
13
+ track the upload operation:
14
+
15
+ +-----+
16
+ public interface ProgressAsyncHandler<T> extends AsyncHandler<T> {
17
+ STATE onHeaderWriteCompleted();
18
+ STATE onContentWriteCompleted();
19
+ STATE onContentWriteProgress(long amount, long current, long total);
20
+ }
21
+ +-----+
22
+
23
+ The methods are called in the following order:
24
+
25
+ * <<<onHeaderWriteCompleted>>>: invoked when the headers has been flushed to the remote server
26
+
27
+ * <<<onContentWriteProgress>>>: as soon as some response's body bytes are written. Might be invoked many times.
28
+
29
+ * <<<onContentWriteCompleted>>>: invoked when the response has been sent or aborted.
30
+
31
+
32
+ Like with <<<AsyncHandler>>>, you can always always abort the processing at any moment in the upload process.
You can’t perform that action at this time.
0 commit comments