mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
* Fixes #3926
* Encode media file name
* Revert "Fixes #3926"
This reverts commit b208b3d7fd.
* Encode fileName to support unicode characters in MultiPartUpload
Refer https://stackoverflow.com/questions/58869988/unexpected-char-0x662-at-42-in-content-disposition-value-form-data-name-userf
This commit is contained in:
parent
e2ba80c342
commit
f496b9dfd2
1 changed files with 11 additions and 1 deletions
|
|
@ -3,6 +3,8 @@ package fr.free.nrw.commons.upload;
|
|||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import org.wikipedia.csrf.CsrfTokenClient;
|
||||
|
||||
import java.io.File;
|
||||
|
|
@ -41,7 +43,15 @@ public class UploadClient {
|
|||
(bytesWritten, contentLength) -> notificationUpdater
|
||||
.onProgress(bytesWritten, contentLength));
|
||||
|
||||
MultipartBody.Part filePart = MultipartBody.Part.createFormData("file", filename, countingRequestBody);
|
||||
MultipartBody.Part filePart;
|
||||
try {
|
||||
filePart = MultipartBody.Part
|
||||
.createFormData("file", URLEncoder.encode(filename, "utf-8"), countingRequestBody);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
filePart = MultipartBody.Part
|
||||
.createFormData("file", filename, countingRequestBody);
|
||||
}
|
||||
RequestBody fileNameRequestBody = RequestBody.create(okhttp3.MultipartBody.FORM, filename);
|
||||
RequestBody tokenRequestBody;
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue