diff --git a/src/main/java/io/appium/java_client/MobileCommand.java b/src/main/java/io/appium/java_client/MobileCommand.java index 421649a72..db80a1601 100644 --- a/src/main/java/io/appium/java_client/MobileCommand.java +++ b/src/main/java/io/appium/java_client/MobileCommand.java @@ -22,6 +22,7 @@ import org.openqa.selenium.remote.CommandInfo; import org.openqa.selenium.remote.http.HttpMethod; +import java.nio.charset.StandardCharsets; import java.time.Duration; import java.util.AbstractMap; import java.util.HashMap; @@ -376,7 +377,7 @@ public static ImmutableMap prepareArguments(String[] params, */ public static Map.Entry> pushFileCommand(String remotePath, byte[] base64Data) { String[] parameters = new String[] {"path", "data"}; - Object[] values = new Object[] {remotePath, base64Data}; + Object[] values = new Object[]{remotePath, new String(base64Data, StandardCharsets.UTF_8)}; return new AbstractMap.SimpleEntry<>(PUSH_FILE, prepareArguments(parameters, values)); } } diff --git a/src/test/java/io/appium/java_client/android/AndroidDriverTest.java b/src/test/java/io/appium/java_client/android/AndroidDriverTest.java index 0afbd7399..5459323ff 100644 --- a/src/test/java/io/appium/java_client/android/AndroidDriverTest.java +++ b/src/test/java/io/appium/java_client/android/AndroidDriverTest.java @@ -62,7 +62,7 @@ public class AndroidDriverTest extends BaseAndroidTest { .getBytes()); driver.pushFile("/data/local/tmp/remote.txt", data); byte[] returnData = driver.pullFile("/data/local/tmp/remote.txt"); - String returnDataDecoded = new String(Base64.decodeBase64(returnData)); + String returnDataDecoded = new String(returnData); assertEquals( "The eventual code is no more than the deposit of your understanding. ~E. W. Dijkstra", returnDataDecoded); @@ -75,7 +75,7 @@ public class AndroidDriverTest extends BaseAndroidTest { + "more than the deposit of your understanding. ~E. W. Dijkstra", "UTF-8", true); driver.pushFile("/data/local/tmp/remote2.txt", temp); byte[] returnData = driver.pullFile("/data/local/tmp/remote2.txt"); - String returnDataDecoded = new String(Base64.decodeBase64(returnData)); + String returnDataDecoded = new String(returnData); assertEquals( "The eventual code is no more than the deposit of " + "your understanding. ~E. W. Dijkstra",