diff options
| author | SammysHP <sven@sammyshp.de> | 2012-05-12 17:04:38 +0200 |
|---|---|---|
| committer | SammysHP <sven@sammyshp.de> | 2012-05-12 17:04:38 +0200 |
| commit | 23d802c7d9cab9629fec978c9c1781de85c6f151 (patch) | |
| tree | 87ac3836e059b9c40d5bafe8a60d5f64f31dcdef | |
| parent | 55947617aa1a12b2126237741e250822694342f2 (diff) | |
| parent | e21344ff9a2c2acdadea7a9e2b659d1febcf9ae0 (diff) | |
| download | cgeo-23d802c7d9cab9629fec978c9c1781de85c6f151.zip cgeo-23d802c7d9cab9629fec978c9c1781de85c6f151.tar.gz cgeo-23d802c7d9cab9629fec978c9c1781de85c6f151.tar.bz2 | |
Merge remote-tracking branch 'samueltardieu/file-upload'
| -rw-r--r-- | main/.classpath | 7 | ||||
| -rw-r--r-- | main/libs/commons-codec-1.4.jar | bin | 0 -> 58160 bytes | |||
| -rw-r--r-- | main/libs/commons-logging-1.1.1.jar | bin | 0 -> 60686 bytes | |||
| -rw-r--r-- | main/libs/httpclient-4.1.3.jar | bin | 0 -> 352585 bytes | |||
| -rw-r--r-- | main/libs/httpcore-4.1.4.jar | bin | 0 -> 181409 bytes | |||
| -rw-r--r-- | main/libs/httpmime-4.1.3.jar | bin | 0 -> 26938 bytes | |||
| -rw-r--r-- | main/proguard.cfg | 12 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/network/Network.java | 33 |
8 files changed, 51 insertions, 1 deletions
diff --git a/main/.classpath b/main/.classpath index 44706dc..be82b10 100644 --- a/main/.classpath +++ b/main/.classpath @@ -2,13 +2,18 @@ <classpath> <classpathentry kind="src" path="src"/> <classpathentry kind="src" path="gen"/> - <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> <classpathentry exported="true" kind="lib" path="libs/commons-lang3-3.1.jar"/> <classpathentry kind="lib" path="libs/locus-api-4.0.jar"/> <classpathentry kind="lib" path="libs/commons-collections-3.2.1.jar"/> <classpathentry kind="lib" path="libs/android-support-v4.jar"/> <classpathentry kind="lib" path="libs/mapsforge-map-0.3.0-jar-with-dependencies.jar"/> <classpathentry kind="lib" path="libs/mapsforge-map-0.2.4.jar"/> + <classpathentry kind="lib" path="libs/commons-codec-1.4.jar"/> + <classpathentry kind="lib" path="libs/commons-logging-1.1.1.jar"/> + <classpathentry kind="lib" path="libs/httpclient-4.1.3.jar"/> + <classpathentry kind="lib" path="libs/httpcore-4.1.4.jar"/> + <classpathentry kind="lib" path="libs/httpmime-4.1.3.jar"/> + <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> <classpathentry kind="output" path="bin/classes"/> </classpath> diff --git a/main/libs/commons-codec-1.4.jar b/main/libs/commons-codec-1.4.jar Binary files differnew file mode 100644 index 0000000..458d432 --- /dev/null +++ b/main/libs/commons-codec-1.4.jar diff --git a/main/libs/commons-logging-1.1.1.jar b/main/libs/commons-logging-1.1.1.jar Binary files differnew file mode 100644 index 0000000..1deef14 --- /dev/null +++ b/main/libs/commons-logging-1.1.1.jar diff --git a/main/libs/httpclient-4.1.3.jar b/main/libs/httpclient-4.1.3.jar Binary files differnew file mode 100644 index 0000000..dfa8793 --- /dev/null +++ b/main/libs/httpclient-4.1.3.jar diff --git a/main/libs/httpcore-4.1.4.jar b/main/libs/httpcore-4.1.4.jar Binary files differnew file mode 100644 index 0000000..1606a2e --- /dev/null +++ b/main/libs/httpcore-4.1.4.jar diff --git a/main/libs/httpmime-4.1.3.jar b/main/libs/httpmime-4.1.3.jar Binary files differnew file mode 100644 index 0000000..ff2014f --- /dev/null +++ b/main/libs/httpmime-4.1.3.jar diff --git a/main/proguard.cfg b/main/proguard.cfg index 5c21420..99088f9 100644 --- a/main/proguard.cfg +++ b/main/proguard.cfg @@ -7,6 +7,15 @@ -dontwarn java.beans.* -dontwarn org.mapsforge.android.maps.Test* -dontwarn android.support.v4.** +-dontwarn org.apache.commons.logging.impl.** +-dontwarn org.apache.commons.logging.LogSource +-dontwarn org.apache.http.impl.auth.NegotiateScheme +-dontwarn android.net.http.AndroidHttpClient +-dontwarn org.apache.log4j.** +-dontwarn org.apache.http.impl.client.cache.** +-dontwarn org.apache.commons.logging.** +-dontwarn org.apache.http.impl.auth.NegotiateScheme +-dontwarn android.net.http.AndroidHttpClient -keep public class * extends android.app.Activity -keep public class * extends android.app.Application @@ -15,6 +24,9 @@ -keep public class * extends android.content.ContentProvider -keep public class cgeo.geocaching.* -keep class android.support.v4.os.** { *; } +-keep class org.apache.http.conn.scheme.** { *; } +-keep class org.apache.http.params.** { *; } +-keep class org.apache.http.client.** { *; } -keepclasseswithmembers class * { public <init>(android.content.Context, android.util.AttributeSet); diff --git a/main/src/cgeo/geocaching/network/Network.java b/main/src/cgeo/geocaching/network/Network.java index 55f6377..2c84c9c 100644 --- a/main/src/cgeo/geocaching/network/Network.java +++ b/main/src/cgeo/geocaching/network/Network.java @@ -20,6 +20,9 @@ import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpRequestBase; import org.apache.http.entity.HttpEntityWrapper; +import org.apache.http.entity.mime.MultipartEntity; +import org.apache.http.entity.mime.content.FileBody; +import org.apache.http.entity.mime.content.StringBody; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.params.BasicHttpParams; import org.apache.http.params.CoreConnectionPNames; @@ -130,6 +133,36 @@ public abstract class Network { } /** + * Multipart POST HTTP request + * + * @param uri the URI to request + * @param params the parameters to add to the POST request + * @param fileFieldName the name of the file field name + * @param fileContentType the content-type of the file + * @param file the file to include in the request + * @return the HTTP response, or null in case of an encoding error param + */ + public static HttpResponse postRequest(final String uri, final Parameters params, + final String fileFieldName, final String fileContentType, final File file) { + final MultipartEntity entity = new MultipartEntity(); + for (final NameValuePair param : params) { + try { + entity.addPart(param.getName(), new StringBody(param.getValue())); + } catch (final UnsupportedEncodingException e) { + Log.e("Network.postRequest: unsupported encoding for parameter " + param.getName(), e); + return null; + } + } + entity.addPart(fileFieldName, new FileBody(file, fileContentType)); + + final HttpPost request = new HttpPost(uri); + request.setEntity(entity); + + addHeaders(request, null, null); + return doRepeatedRequests(request); + } + + /** * Make an HTTP request * * @param method |
