author: ljy date: 2018/11/27 description: retrofit的请求接口定义 https://www.jianshu.com/p/092452f287db
| 18 | */ |
| 19 | |
| 20 | public interface ApiService { |
| 21 | |
| 22 | /** |
| 23 | * 获取豆瓣正在上映电影的接口 |
| 24 | * @param start 起始页码 |
| 25 | * @param count 获取的电影数量 |
| 26 | * @return |
| 27 | */ |
| 28 | @GET("v2/movie/in_theaters") |
| 29 | Observable<Result> getPlayingMovie(@Query("start") int start, @Query("count") int count); |
| 30 | |
| 31 | /** |
| 32 | * 模拟上传文件的接口 |
| 33 | * @param uploadUrl 上传地址 |
| 34 | * @param requestBody 上传实体 |
| 35 | * @return |
| 36 | */ |
| 37 | @Multipart |
| 38 | @POST |
| 39 | Observable<Object> upLoadFile(@Url String uploadUrl, @Part("fileKey\"; filename=\"upload.java") RequestBody requestBody); |
| 40 | |
| 41 | //下载大文件时,请加上@Streaming,否则容易出现IO异常 |
| 42 | //目前使用@Streaming进行下载的话,需添加Log拦截器(且LEVEL为BODY)才不会报错,但是网上又说添加Log拦截器后进行下载容易OOM, |
| 43 | //所以这一块还很懵,具体原因也不清楚,有知道的朋友可以告诉下我) |
| 44 | // @Streaming |
| 45 | @GET |
| 46 | Observable<ResponseBody> downloadFile(@Url String downloadUrl); |
| 47 | } |