From 39ac574d0c31770217b75555c1f7eb1f0c229a7b Mon Sep 17 00:00:00 2001 From: e <511455842@qq.com> Date: Mon, 12 Feb 2018 21:08:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=94=AF=E6=8C=81post?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Aria/build.gradle | 4 ++-- .../aria/core/upload/uploader/HttpThreadTask.java | 2 ++ .../com/arialyy/simple/upload/HttpUploadActivity.java | 10 ++++++---- .../com/arialyy/aria/core/upload/UploadTaskEntity.java | 2 +- build.gradle | 2 +- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Aria/build.gradle b/Aria/build.gradle index f95e9d8f..4d7ee364 100644 --- a/Aria/build.gradle +++ b/Aria/build.gradle @@ -23,8 +23,8 @@ dependencies { testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1' compile project(':AriaAnnotations') -// compile 'com.arialyy.aria:aria-ftp-plug:1.0.3' + compile 'com.arialyy.aria:aria-ftp-plug:1.0.3' - compile project(':AriaFtpPlug') +// compile project(':AriaFtpPlug') } apply from: 'bintray-release.gradle' diff --git a/Aria/src/main/java/com/arialyy/aria/core/upload/uploader/HttpThreadTask.java b/Aria/src/main/java/com/arialyy/aria/core/upload/uploader/HttpThreadTask.java index 8783aaeb..3143737f 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/upload/uploader/HttpThreadTask.java +++ b/Aria/src/main/java/com/arialyy/aria/core/upload/uploader/HttpThreadTask.java @@ -65,9 +65,11 @@ class HttpThreadTask extends AbsThreadTask { try { url = new URL(mEntity.getUrl()); mHttpConn = (HttpURLConnection) url.openConnection(); + mHttpConn.setRequestMethod(mTaskEntity.requestEnum.name); mHttpConn.setUseCaches(false); mHttpConn.setDoOutput(true); mHttpConn.setDoInput(true); + mHttpConn.setRequestProperty("Connection", "Keep-Alive"); mHttpConn.setRequestProperty("Content-Type", mTaskEntity.contentType + "; boundary=" + BOUNDARY); mHttpConn.setRequestProperty("User-Agent", mTaskEntity.userAgent); diff --git a/app/src/main/java/com/arialyy/simple/upload/HttpUploadActivity.java b/app/src/main/java/com/arialyy/simple/upload/HttpUploadActivity.java index 92089de2..c0b942c7 100644 --- a/app/src/main/java/com/arialyy/simple/upload/HttpUploadActivity.java +++ b/app/src/main/java/com/arialyy/simple/upload/HttpUploadActivity.java @@ -21,6 +21,7 @@ import butterknife.Bind; import butterknife.OnClick; import com.arialyy.annotations.Upload; import com.arialyy.aria.core.Aria; +import com.arialyy.aria.core.common.RequestEnum; import com.arialyy.aria.core.upload.UploadTask; import com.arialyy.frame.util.FileUtil; import com.arialyy.frame.util.show.L; @@ -37,7 +38,7 @@ public class HttpUploadActivity extends BaseActivity { private static final String TAG = "HttpUploadActivity"; @Bind(R.id.pb) HorizontalProgressBarWithNumber mPb; - private static final String FILE_PATH = "/mnt/sdcard/test.txt"; + private static final String FILE_PATH = "/mnt/sdcard/test.apk"; @Override protected int setLayoutId() { return R.layout.activity_upload; @@ -51,10 +52,11 @@ public class HttpUploadActivity extends BaseActivity { @OnClick(R.id.upload) void upload() { Aria.upload(HttpUploadActivity.this).load(FILE_PATH) - //.setUploadUrl( - // "http://lib-test.xzxyun.com:8042/Api/upload?data={\"type\":\"1\",\"fileType\":\".txt\"}") - .setUploadUrl("http://192.168.1.6:8080/upload/sign_file/").setAttachment("file") + .setUploadUrl( + "http://lib-test.xzxyun.com:8042/Api/upload?data={\"type\":\"1\",\"fileType\":\".apk\"}") + //.setUploadUrl("http://192.168.1.6:8080/upload/sign_file/").setAttachment("file") //.addHeader("iplanetdirectorypro", "11a09102fb934ad0bc206f9c611d7933") + .setRequestMode(RequestEnum.POST) .start(); } diff --git a/aria/src/main/java/com/arialyy/aria/core/upload/UploadTaskEntity.java b/aria/src/main/java/com/arialyy/aria/core/upload/UploadTaskEntity.java index 11410be7..83ad03af 100644 --- a/aria/src/main/java/com/arialyy/aria/core/upload/UploadTaskEntity.java +++ b/aria/src/main/java/com/arialyy/aria/core/upload/UploadTaskEntity.java @@ -27,7 +27,7 @@ import java.util.Map; public class UploadTaskEntity extends AbsNormalTaskEntity { public String attachment; //文件上传需要的key public String contentType = "multipart/form-data"; //上传的文件类型 - public String userAgent = "User-Agent"; + public String userAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-CN; rv:1.9.2.6)"; @OneToOne(table = UploadEntity.class, key = "filePath") public UploadEntity entity; public String filePath = ""; diff --git a/build.gradle b/build.gradle index 40de7a5e..c525f86b 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.14' + publishVersion = '3.3.15' // publishVersion = '1.0.3' //FTP插件 repoName='maven' desc = 'android 下载框架'