Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 8 additions & 17 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
classpath 'com.github.dcendents:android-maven-plugin:1.2'
classpath 'com.android.tools.build:gradle:1.5.0+'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0+'
classpath 'com.github.dcendents:android-maven-plugin:1.2+'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
jcenter()
Expand Down
17 changes: 8 additions & 9 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.

## Project-wide Gradle settings.
#
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

#
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

#
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# org.gradle.parallel=true
#Tue Dec 01 15:45:05 CST 2015
systemProp.http.proxyHost=127.0.0.1
systemProp.http.proxyPort=1080
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
33 changes: 1 addition & 32 deletions okhttputils/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'

version = "1.0.2"
Expand Down Expand Up @@ -30,37 +29,7 @@ def siteUrl = 'https://github.com/hongyangAndroid/okhttp-utils'
def gitUrl = 'https://github.com/hongyangAndroid/okhttp-utils.git' // #CONFIG# // project git
group = "com.zhy"

install {
repositories.mavenInstaller {
// This generates POM.xml with proper parameters
pom {
project {
packaging 'aar'
name 'okhttputils' // #CONFIG# // project title
url siteUrl
// Set your license
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id 'hongyangAndroid' // #CONFIG# // your user id (you can write your nickname)
name 'ZhangHongyang' // #CONFIG# // your user name
email '623565791@qq.com' // #CONFIG# // your email
}
}
scm {
connection gitUrl
developerConnection gitUrl
url siteUrl
}
}
}
}
}


task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
Expand Down
101 changes: 0 additions & 101 deletions okhttputils/okhttputils.iml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.zhy.http.okhttp;

import com.squareup.okhttp.MediaType;
import com.squareup.okhttp.RequestBody;

import java.io.IOException;
import java.io.InputStream;

import okio.BufferedSink;
import okio.Okio;
import okio.Source;

/**
* create InputStream RequestBody
* Created by YUHONG on 2015/12/1.
*
* Email: hongyuahu@gmail.com
*/
public class RequestBodyUtils {

public static RequestBody create(final MediaType mediaType, final InputStream inputStream) {
return new RequestBody() {
@Override
public MediaType contentType() {
return mediaType;
}

@Override
public void writeTo(BufferedSink sink) throws IOException {
Source source = null;
try {
source = Okio.source(inputStream);
sink.writeAll(source);
} finally {

}
}

@Override
public long contentLength() throws IOException {
try {
return inputStream.available();
} catch ( IOException e) {
return 0;
}
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.IdentityHashMap;
import java.util.Map;

Expand Down Expand Up @@ -105,6 +106,7 @@ public static class Builder
private Map<String, String> headers;
private Map<String, String> params;
private Pair<String, File>[] files;
private Pair<String, InputStream>[] inputStreams;
private MediaType mediaType;

private String destFileDir;
Expand Down Expand Up @@ -162,6 +164,12 @@ public Builder addHeader(String key, String val)
return this;
}

public Builder inputStreams(Pair<String, InputStream>... inputStreams)
{
this.inputStreams = inputStreams;
return this;
}


public Builder files(Pair<String, File>... files)
{
Expand Down Expand Up @@ -234,14 +242,14 @@ public OkHttpRequest post(ResultCallback callback)

public OkHttpRequest upload(ResultCallback callback)
{
OkHttpRequest request = new OkHttpUploadRequest(url, tag, params, headers, files);
OkHttpRequest request = new OkHttpUploadRequest(url, tag, params, headers, files, inputStreams);
request.invokeAsyn(callback);
return request;
}

public <T> T upload(Class<T> clazz) throws IOException
{
OkHttpRequest request = new OkHttpUploadRequest(url, tag, params, headers, files);
OkHttpRequest request = new OkHttpUploadRequest(url, tag, params, headers, files, inputStreams);
return request.invoke(clazz);
}

Expand Down
Loading