public static Observable < byte [ ] > downloadFileAsync ( String url , Retrofit retrofit ) { FileService service = retrofit . create ( FileService . class ) ; Observable < ResponseBody > response = service . download ( url ) ; return response . map ( new Func1 < ResponseBody , byte [ ] > ( ) { @ Override public byte [ ] call ( ResponseBody responseBody ) { try { return responseBody . bytes ( ) ; } catch ( IOException e ) { throw Exceptions . propagate ( e ) ; } } } ) ; }
Download a file asynchronously .