Skip to content

Commit e9add69

Browse files
authored
feat: [Android] adding support for UTF8-characters on multi part uploads (#168)
1 parent e043d16 commit e9add69

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ const options = {
100100
// Below are options only supported on Android
101101
notification: {
102102
enabled: true
103-
}
103+
},
104+
useUtf8Charset: true
104105
}
105106
106107
Upload.startUpload(options).then((uploadId) => {
@@ -166,6 +167,7 @@ Returns a promise with the string ID of the upload. Will reject if there is a c
166167
|`field`|string|Required if `type: 'multipart'`||The form field name for the file. Only used when `type: 'multipart`|`uploaded-file`|
167168
|`parameters`|object|Optional||Additional form fields to include in the HTTP request. Only used when `type: 'multipart`||
168169
|`notification`|Notification object (see below)|Optional||Android only. |`{ enabled: true, onProgressTitle: "Uploading...", autoClear: true }`|
170+
|`useUtf8Charset`|boolean|Optional||Android only. Set to true to use `utf-8` as charset. ||
169171

170172
### Notification Object (Android Only)
171173
|Name|Type|Required|Description|Example|

android/src/main/java/com/vydia/UploaderModule.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,14 @@ public void startUpload(ReadableMap options, final Promise promise) {
175175
return;
176176
}
177177

178-
request = new MultipartUploadRequest(this.getReactApplicationContext(), customUploadId, url)
179-
.addFileToUpload(filePath, options.getString("field"));
178+
if(options.hasKey("useUtf8Charset") && options.getBoolean("useUtf8Charset")) {
179+
request = new MultipartUploadRequest(this.getReactApplicationContext(), customUploadId, url)
180+
.setUtf8Charset()
181+
.addFileToUpload(filePath, options.getString("field"));
182+
} else {
183+
request = new MultipartUploadRequest(this.getReactApplicationContext(), customUploadId, url)
184+
.addFileToUpload(filePath, options.getString("field"));
185+
}
180186
}
181187

182188

0 commit comments

Comments
 (0)