上传支持post

pull/330/head
e 7 years ago
parent ebddc510ca
commit 39ac574d0c
  1. 4
      Aria/build.gradle
  2. 2
      Aria/src/main/java/com/arialyy/aria/core/upload/uploader/HttpThreadTask.java
  3. 10
      app/src/main/java/com/arialyy/simple/upload/HttpUploadActivity.java
  4. 2
      aria/src/main/java/com/arialyy/aria/core/upload/UploadTaskEntity.java
  5. 2
      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'

@ -65,9 +65,11 @@ class HttpThreadTask extends AbsThreadTask<UploadEntity, UploadTaskEntity> {
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);

@ -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<ActivityUploadBinding> {
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<ActivityUploadBinding> {
@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();
}

@ -27,7 +27,7 @@ import java.util.Map;
public class UploadTaskEntity extends AbsNormalTaskEntity<UploadEntity> {
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 = "";

@ -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 下载框架'

Loading…
Cancel
Save