Created
November 25, 2010 01:03
-
-
Save jfarcand/714743 to your computer and use it in GitHub Desktop.
Resumable download which support IOException and JVM shutdown
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Properties Based resumable download | |
AsyncHttpClient c = new AsyncHttpClient(); | |
ResumableAsyncHandler a = new ResumableAsyncHandler(new PropertiesBasedResumableProcessor()); | |
a.addResumableListener(new ResumableRandomAccessFileHandler(new RandomAccessFile("800m.avi", "rw"))); | |
Response r = c.prepareGet("http://192.168.2.106:8081/800m.avi").execute(a).get(); | |
// File based resumable download | |
AsyncHttpClient c = new AsyncHttpClient(); | |
RandomAccessFile f = new RandomAccessFile("800m.avi", "rw"); | |
ResumableAsyncHandler a = new ResumableAsyncHandler( | |
new FileBasedResumableProcessor("http://192.168.2.106:8081/800m.avi", f)); | |
a.addResumableListener(new ResumableRandomAccessFileHandler(f)); | |
Response r = c.prepareGet("http://192.168.2.106:8081/800m.avi").execute(a).get(); | |
// IOException, Network outage resumable download. | |
AsyncHttpClient c = new AsyncHttpClient(new AsyncHttpClientConfig.Builder() | |
.addIOExceptionFilter(new ResumableIOExceptionFilter()).build()); | |
ResumableAsyncHandler a = new ResumableAsyncHandler(); | |
Response r = c.prepareGet("http://192.168.2.106:8081/800m.avi").execute(a).get(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment