mirror of
https://github.com/apache/cordova-plugin-file-transfer.git
synced 2026-07-13 00:10:15 +08:00
CB-9022 Resolve source URI on background thread
We should call remapUri on background thread otherwise it throws IllegalStateException when trying to remap 'cdvfile://localhost/content/...' URIs via ContentFilesystem
This commit is contained in:
@@ -305,10 +305,6 @@ public class FileTransfer extends CordovaPlugin {
|
|||||||
Log.d(LOG_TAG, "httpMethod: " + httpMethod);
|
Log.d(LOG_TAG, "httpMethod: " + httpMethod);
|
||||||
|
|
||||||
final Uri targetUri = resourceApi.remapUri(Uri.parse(target));
|
final Uri targetUri = resourceApi.remapUri(Uri.parse(target));
|
||||||
// Accept a path or a URI for the source.
|
|
||||||
Uri tmpSrc = Uri.parse(source);
|
|
||||||
final Uri sourceUri = resourceApi.remapUri(
|
|
||||||
tmpSrc.getScheme() != null ? tmpSrc : Uri.fromFile(new File(source)));
|
|
||||||
|
|
||||||
int uriType = CordovaResourceApi.getUriType(targetUri);
|
int uriType = CordovaResourceApi.getUriType(targetUri);
|
||||||
final boolean useHttps = uriType == CordovaResourceApi.URI_TYPE_HTTPS;
|
final boolean useHttps = uriType == CordovaResourceApi.URI_TYPE_HTTPS;
|
||||||
@@ -329,6 +325,14 @@ public class FileTransfer extends CordovaPlugin {
|
|||||||
if (context.aborted) {
|
if (context.aborted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We should call remapUri on background thread otherwise it throws
|
||||||
|
// IllegalStateException when trying to remap 'cdvfile://localhost/content/...' URIs
|
||||||
|
// via ContentFilesystem (see https://issues.apache.org/jira/browse/CB-9022)
|
||||||
|
Uri tmpSrc = Uri.parse(source);
|
||||||
|
final Uri sourceUri = resourceApi.remapUri(
|
||||||
|
tmpSrc.getScheme() != null ? tmpSrc : Uri.fromFile(new File(source)));
|
||||||
|
|
||||||
HttpURLConnection conn = null;
|
HttpURLConnection conn = null;
|
||||||
HostnameVerifier oldHostnameVerifier = null;
|
HostnameVerifier oldHostnameVerifier = null;
|
||||||
SSLSocketFactory oldSocketFactory = null;
|
SSLSocketFactory oldSocketFactory = null;
|
||||||
@@ -686,7 +690,7 @@ public class FileTransfer extends CordovaPlugin {
|
|||||||
if(body != null)
|
if(body != null)
|
||||||
{
|
{
|
||||||
error.put("body", body);
|
error.put("body", body);
|
||||||
}
|
}
|
||||||
if (httpStatus != null) {
|
if (httpStatus != null) {
|
||||||
error.put("http_status", httpStatus);
|
error.put("http_status", httpStatus);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user