Skip to content

Commit 39c1096

Browse files
committed
fix: readableMap for header
1 parent a3c8694 commit 39c1096

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

android/src/main/java/com/reactnativecompressor/Utils/FileUplaoder/FileUploadHelper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static FileUploadHelper fromMap(ReadableMap map) {
2121
break;
2222

2323
case "headers":
24-
options.headers = map.getString(key);
24+
options.headers = map.getMap(key);
2525
break;
2626

2727
case "url":
@@ -34,6 +34,6 @@ public static FileUploadHelper fromMap(ReadableMap map) {
3434
}
3535
public String uuid;
3636
public String method;
37-
public String headers;
37+
public ReadableMap headers;
3838
public String url;
3939
}

android/src/main/java/com/reactnativecompressor/Utils/FileUplaoder/FileUploader.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,11 @@ protected String doInBackground(String... params) {
7171
try {
7272
String upLoadServerUri =this.options.url;
7373

74-
// open a URL connection to the Servlet
7574
FileInputStream fileInputStream = new FileInputStream(
7675
sourceFile);
7776
URL url = new URL(upLoadServerUri);
78-
// Open a HTTP connection to the URL
7977
conn = (HttpURLConnection) url.openConnection();
80-
conn.setDoOutput(true); // Allow Outputs
81-
conn.setDoInput(true); // Allow Inputs
78+
8279
ReadableMapKeySetIterator headerIterator = this.options.headers.keySetIterator();
8380
while (headerIterator.hasNextKey()) {
8481
String key = headerIterator.nextKey();
@@ -89,8 +86,6 @@ protected String doInBackground(String... params) {
8986

9087
conn.setUseCaches(false); // Don't use a Cached Copy
9188
conn.setRequestMethod(this.options.method);
92-
conn.setDoOutput(true);
93-
conn.setRequestProperty("Connection", "Keep-Alive");
9489
conn.setRequestProperty("file", sourceFileUri);
9590
conn.connect();
9691
dos = new DataOutputStream(conn.getOutputStream());
@@ -134,7 +129,9 @@ protected String doInBackground(String... params) {
134129
if (conn.getResponseCode() == 200) {
135130
Log.d(TAG, "doInBackground: upload successfully");
136131
sendProgressEvent(1);
137-
this.promise.resolve("");
132+
WritableMap param = Arguments.createMap();
133+
param.putInt("status",conn.getResponseCode());
134+
this.promise.resolve(param);
138135
}
139136
else
140137
{

0 commit comments

Comments
 (0)