piso_mojado 0 Newbie Poster

running into an issue haven't seen this before where content during the encoding and decoding of an image looses byte count.

I have an app taking the photo image and sending the file via:

-----------------------

byte[] imageBytes = new byte[(int) imageFile.length()];

inputFile = new RandomAccessFile(imageFile, "r");
inputFile.read(imageBytes);

String base64String = Base64.encodeToString(imageBytes, Base64.DEFAULT);

------------------------

id Base64string goes across the soapenv request
like:

------------------------

var sr = '<?xml version="1.0" encoding="utf-8"?>' +
'<soapenv:Envelope ' + 
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' +
'xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" ' +
'xmlns:urn="urn:DefaultNamespace">'+
'<soapenv:Header/>'+
'<soapenv:Body>' +
'<urn:addNewFileComplex soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">' +
'<daFile xsi:type="urn:lookupAssessmentFile">' +
'<base64File xsi:type="soapenc:base64" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">cid:560948411422</base64File>' +
'<UserName xsi:type="xsd:string">'+uname+'</UserName>' +
'<Password xsi:type="xsd:string">'+pwd+'</Password>' +
'<Seq xsi:type="xsd:string">'+seq+'</Seq>' +
'<noteID xsi:type="xsd:string">'+noid+'</noteID>' +
'<da_incident xsi:type="xsd:string">'+incName+'</da_incident>' +
'<da_incidentid xsi:type="xsd:string">'+incID+'</da_incidentid>' +
'<da_createdon xsi:type="xsd:string">'+dCreated+'</da_createdon>' +
'<fileName xsi:type="xsd:string">'+fileName+'</fileName>' +

--------------------

The web request creates the document and adds the field data and I even get the attachment embedded.

The issue is that if the original jpeg is 59k, I get an image file of 48k in size.

I verify the log on the originating bit count and get 59037 byte stream.

On domino when actions performed via:

----------------

if (tempFile == null)
tempFile = File.createTempFile("Tempfile-", ".b64", new File(getTempDir()));

//System.out.println("received byte count is: "+base64bytes.length);

ByteArrayInputStream in = new ByteArrayInputStream(base64bytes);
FileOutputStream out = new FileOutputStream(tempFile);
BASE64Decoder decoder = new BASE64Decoder();
decoder.decodeBuffer(in, out);
System.out.println("tempfile is: "+tempFile);
System.out.println("tempfile length is: "+base64bytes.length);
in.close();
out.close();
..

base64bytes.length is lower than when it was sent after decoded method is used on the domino server.

Has anyone been able to get the image file re-conformed on the resulting side?

UTF-8 is used and have changed content-type on the soap header to "image/jpg" with no success.

Thanks,

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.