Skip to content
This repository was archived by the owner on Mar 16, 2019. It is now read-only.

Commit c3cc1dd

Browse files
committed
Fix incorrect field name when using multipart body on android.
1 parent cf9c8f1 commit c3cc1dd

File tree

5 files changed

+31
-3
lines changed

5 files changed

+31
-3
lines changed

android/.idea/gradle.xml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

android/.idea/misc.xml

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

android/build.gradle

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
apply plugin: 'com.android.library'
22

3+
repositories {
4+
mavenCentral()
5+
}
6+
7+
buildscript {
8+
repositories {
9+
mavenCentral()
10+
}
11+
dependencies {
12+
classpath 'com.android.tools.build:gradle:2.0.0'
13+
}
14+
}
15+
316
android {
417
compileSdkVersion 23
518
buildToolsVersion "23.0.3"

android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#Mon Dec 28 10:00:20 PST 2015
1+
#Wed May 18 12:33:41 CST 2016
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME

android/src/main/java/com/RNFetchBlob/RNFetchBlob.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ public void fetchBlobForm(String method, String url, ReadableMap headers, Readab
138138
for(int i =0; i<body.size() ; i++) {
139139
ReadableMap map = body.getMap(i);
140140
String name = map.getString("name");
141+
// file field
141142
if(map.hasKey("filename")) {
142143
String filename = map.getString("filename");
143144
byte [] file = Base64.decode(map.getString("data"), 0);
@@ -147,10 +148,11 @@ public void fetchBlobForm(String method, String url, ReadableMap headers, Readab
147148
outputStream.write(file);
148149
outputStream.write("\r\n".getBytes());
149150
}
151+
// data field
150152
else {
151153
String data = map.getString("data");
152154
outputStream.write(String.format("--%s\r\n", boundary).getBytes("UTF-8"));
153-
outputStream.write(String.format("Content-Disposition: form-data; name=\"%s\"; \r\n", boundary, name).getBytes("UTF-8"));
155+
outputStream.write(String.format("Content-Disposition: form-data; name=\"%s\"; \r\n", name).getBytes("UTF-8"));
154156
outputStream.write(String.format("Content-Type: text/plain\r\n\r\n").getBytes());
155157
outputStream.write((data+"\r\n").getBytes());
156158
}

0 commit comments

Comments
 (0)