mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-02 09:21:44 +08:00
add progressListener for android when using FormData to upload files
Summary: When using FormData upload images or files, in Android version, network module cannot send an event for showing progress. This PR will solve this issue. I changed example in XHRExample for Android, you can see uploading progress in warning yellow bar. Closes https://github.com/facebook/react-native/pull/7256 Differential Revision: D3390087 fbshipit-source-id: 7f3e53c80072fff397afd6f5fe17bf0f2ecd83b2
This commit is contained in:
committed by
Facebook Github Bot 7
parent
0f35f7c6d5
commit
e63ea3acc4
@@ -60,6 +60,8 @@ import static org.mockito.Mockito.when;
|
||||
Arguments.class,
|
||||
Call.class,
|
||||
RequestBodyUtil.class,
|
||||
ProgressRequestBody.class,
|
||||
ProgressRequestListener.class,
|
||||
MultipartBody.class,
|
||||
MultipartBody.Builder.class,
|
||||
NetworkingModule.class,
|
||||
@@ -262,6 +264,7 @@ public class NetworkingModuleTest {
|
||||
.thenReturn(mock(InputStream.class));
|
||||
when(RequestBodyUtil.create(any(MediaType.class), any(InputStream.class)))
|
||||
.thenReturn(mock(RequestBody.class));
|
||||
when(RequestBodyUtil.createProgressRequest(any(RequestBody.class), any(ProgressRequestListener.class))).thenCallRealMethod();
|
||||
|
||||
JavaOnlyMap body = new JavaOnlyMap();
|
||||
JavaOnlyArray formData = new JavaOnlyArray();
|
||||
@@ -316,6 +319,7 @@ public class NetworkingModuleTest {
|
||||
.thenReturn(mock(InputStream.class));
|
||||
when(RequestBodyUtil.create(any(MediaType.class), any(InputStream.class)))
|
||||
.thenReturn(mock(RequestBody.class));
|
||||
when(RequestBodyUtil.createProgressRequest(any(RequestBody.class), any(ProgressRequestListener.class))).thenCallRealMethod();
|
||||
|
||||
List<JavaOnlyArray> headers = Arrays.asList(
|
||||
JavaOnlyArray.of("Accept", "text/plain"),
|
||||
@@ -378,6 +382,7 @@ public class NetworkingModuleTest {
|
||||
when(RequestBodyUtil.getFileInputStream(any(ReactContext.class), any(String.class)))
|
||||
.thenReturn(inputStream);
|
||||
when(RequestBodyUtil.create(any(MediaType.class), any(InputStream.class))).thenCallRealMethod();
|
||||
when(RequestBodyUtil.createProgressRequest(any(RequestBody.class), any(ProgressRequestListener.class))).thenCallRealMethod();
|
||||
when(inputStream.available()).thenReturn("imageUri".length());
|
||||
|
||||
final MultipartBody.Builder multipartBuilder = mock(MultipartBody.Builder.class);
|
||||
|
||||
Reference in New Issue
Block a user