diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTarget.java b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTarget.java index d1c9d53f..5a8b20ed 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTarget.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTarget.java @@ -62,6 +62,18 @@ public class DownloadTarget mTaskEntity.refreshInfo = refreshInfo; } + /** + * 是否使用服务器通过content-disposition传递的文件名,内容格式{@code attachment;filename=***} + * 如果获取不到服务器文件名,则使用用户设置的文件名 + * 只适用于HTTP请求 + * + * @param use {@code true} 使用 + */ + @Deprecated public DownloadTarget useServerFileName(boolean use) { + mTaskEntity.useServerFileName = use; + return this; + } + /** * 将任务设置为最高优先级任务,最高优先级任务有以下特点: * 1、在下载队列中,有且只有一个最高优先级任务 diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/downloader/HttpFileInfoThread.java b/Aria/src/main/java/com/arialyy/aria/core/download/downloader/HttpFileInfoThread.java index 652696d1..64aa80ca 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/downloader/HttpFileInfoThread.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/downloader/HttpFileInfoThread.java @@ -54,6 +54,7 @@ class HttpFileInfoThread implements Runnable { conn = ConnectionHelp.setConnectParam(mTaskEntity, conn); conn.setRequestProperty("Range", "bytes=" + 0 + "-"); conn.setConnectTimeout(mConnectTimeOut); + conn.setRequestMethod(mTaskEntity.requestEnum.name); conn.connect(); handleConnect(conn); } catch (IOException e) { diff --git a/Aria/src/main/java/com/arialyy/aria/core/inf/AbsTarget.java b/Aria/src/main/java/com/arialyy/aria/core/inf/AbsTarget.java index 32d4a935..ea30b47f 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/inf/AbsTarget.java +++ b/Aria/src/main/java/com/arialyy/aria/core/inf/AbsTarget.java @@ -168,7 +168,8 @@ public abstract class AbsTarget extends DbEntity { */ public String md5Key = "Content-MD5"; + /** + * 是否使用服务器通过content-disposition传递的文件名,内容格式{@code attachment;filename=***} + * {@code true} 使用 + */ + public boolean useServerFileName = false; + /** * 从header中获取文件描述信息所需要的key */ diff --git a/DEV_LOG.md b/DEV_LOG.md index 48d2342f..b088dc4f 100644 --- a/DEV_LOG.md +++ b/DEV_LOG.md @@ -1,4 +1,6 @@ ## 开发日志 + + v_3.3.8 + - 添加POST支持 + v_3.3.7 - 修复一个线程重启的问题 https://github.com/AriaLyy/Aria/issues/160 - 修复配置文件异常问题、格式化速度为0问题 https://github.com/AriaLyy/Aria/issues/161 diff --git a/README.md b/README.md index cffa3b82..1b592c21 100644 --- a/README.md +++ b/README.md @@ -28,8 +28,8 @@ Aria有以下特点: [![Download](https://api.bintray.com/packages/arialyy/maven/AriaApi/images/download.svg)](https://bintray.com/arialyy/maven/AriaApi/_latestVersion) [![Download](https://api.bintray.com/packages/arialyy/maven/AriaCompiler/images/download.svg)](https://bintray.com/arialyy/maven/AriaCompiler/_latestVersion) ```java -compile 'com.arialyy.aria:aria-core:3.3.6' -annotationProcessor 'com.arialyy.aria:aria-compiler:3.3.6' +compile 'com.arialyy.aria:aria-core:3.3.7' +annotationProcessor 'com.arialyy.aria:aria-compiler:3.3.7' ``` 如果你使用的是kotlin,请使用kotlin官方提供的方法配置apt,[kotlin kapt官方配置传送门](https://www.kotlincn.net/docs/reference/kapt.html) @@ -74,13 +74,17 @@ protected void onCreate(Bundle savedInstanceState) { ```java //在这里处理任务执行中的状态,如进度进度条的刷新 -@Download.onTaskRunning(DOWNLOAD_URL) protected void running(DownloadTask task) { +@Download.onTaskRunning protected void running(DownloadTask task) { + if(task.getUrl().eques(url)){ + .... + 可以通过url判断是否是指定任务的回调 + } int p = task.getPercent(); //任务进度百分比 String speed = task.getConvertSpeed(); //转换单位后的下载速度,单位转换需要在配置文件中打开 String speed1 = task.getSpeed(); //原始byte长度速度 } -@Download.onTaskComplete(DOWNLOAD_URL) void taskComplete(DownloadTask task) { +@Download.onTaskComplete void taskComplete(DownloadTask task) { //在这里处理任务完成的状态 } ``` @@ -92,7 +96,12 @@ protected void onCreate(Bundle savedInstanceState) { ### [更多说明,见WIKI](https://github.com/AriaLyy/Aria/wiki) -### [历史版本说明](https://github.com/AriaLyy/Aria/blob/master/DEV_LOG.md) +### 升级日志 ++ v_3.3.7 + - 修复一个线程重启的问题 https://github.com/AriaLyy/Aria/issues/160 + - 修复配置文件异常问题、格式化速度为0问题 https://github.com/AriaLyy/Aria/issues/161 + +[更多版本记录](https://github.com/AriaLyy/Aria/blob/master/DEV_LOG.md) ## 混淆配置 ``` diff --git a/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java b/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java index 039e5484..14361bff 100644 --- a/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java +++ b/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java @@ -29,6 +29,7 @@ import butterknife.Bind; import com.arialyy.annotations.Download; import com.arialyy.annotations.DownloadGroup; import com.arialyy.aria.core.Aria; +import com.arialyy.aria.core.common.RequestEnum; import com.arialyy.aria.core.download.DownloadEntity; import com.arialyy.aria.core.download.DownloadGroupTask; import com.arialyy.aria.core.download.DownloadTarget; @@ -216,6 +217,7 @@ public class SingleTaskActivity extends BaseActivity { Aria.download(SingleTaskActivity.this) .load(DOWNLOAD_URL) .addHeader("groupName", "value") + .setRequestMode(RequestEnum.POST) .setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/hhhhhhhh.apk") .start(); } diff --git a/app/src/main/java/com/arialyy/simple/download/group/FTPDirDownloadActivity.java b/app/src/main/java/com/arialyy/simple/download/group/FTPDirDownloadActivity.java index a597a2ad..3342e23e 100644 --- a/app/src/main/java/com/arialyy/simple/download/group/FTPDirDownloadActivity.java +++ b/app/src/main/java/com/arialyy/simple/download/group/FTPDirDownloadActivity.java @@ -35,7 +35,7 @@ import com.arialyy.simple.widget.SubStateLinearLayout; * Created by Aria.Lao on 2017/7/6. */ public class FTPDirDownloadActivity extends BaseActivity { - private static final String dir = "ftp://172.18.104.64:21/upload/测试"; + private static final String dir = "ftp://192.168.1.2:21/upload/测试"; @Bind(R.id.child_list) SubStateLinearLayout mChildList; diff --git a/app/src/main/java/com/arialyy/simple/upload/FtpUploadActivity.java b/app/src/main/java/com/arialyy/simple/upload/FtpUploadActivity.java index ae861527..edc42725 100644 --- a/app/src/main/java/com/arialyy/simple/upload/FtpUploadActivity.java +++ b/app/src/main/java/com/arialyy/simple/upload/FtpUploadActivity.java @@ -35,7 +35,7 @@ import com.arialyy.simple.databinding.ActivityFtpUploadBinding; */ public class FtpUploadActivity extends BaseActivity { private final String FILE_PATH = "/mnt/sdcard/Download/me.jpg"; - private final String URL = "ftp://172.18.104.65:21/upload/测试"; + private final String URL = "ftp://192.168.1.2:21/upload/测试"; @Override protected void init(Bundle savedInstanceState) { setTile("D_FTP 文件上传"); diff --git a/build.gradle b/build.gradle index dceeba05..dca1776b 100644 --- a/build.gradle +++ b/build.gradle @@ -39,7 +39,7 @@ task clean(type: Delete) { ext { userOrg = 'arialyy' groupId = 'com.arialyy.aria' - publishVersion = '3.3.6' + publishVersion = '3.3.7' // publishVersion = '1.0.3' //FTP插件 repoName='maven' desc = 'android 下载框架'