1

我正在尝试使用 ksoap2 作为客户端发送一个 zip 文件...文件已到达但已损坏,我认为当我在 Base64 中对其进行编码时,我的代码中有某些内容(我正在使用公共代码)...

WS

FileInputStream fis = new FileInputStream(path.toString()+zipName.toString());
        byte[] toByteArray = IOUtils.toByteArray(fis);
        byte[] encodeBase64 = Base64.encodeBase64(toByteArray);
        return encodeBase64;

客户

SoapPrimitive soapPrimitive = (SoapPrimitive) soapSerializationEnvelope.getResponse();
        String result = soapPrimitive.toString();
        byte[] decode = Base64.decode(result);
        String formPath = "C:\\Users\\John\\Desktop\\test.zip";
        boolean flag = new File(path.toString()).mkdirs();
        FileOutputStream fileOutputStream = new FileOutputStream(formPath);
        fileOutputStream.write(decode);
        fileOutputStream.flush();
        fileOutputStream.close();

文件在服务器上没问题,我可以打开它,但是当它到达客户端时它已损坏

谢谢...

4

0 回答 0