function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
F.H.KazmiF.H.Kazmi 

Unable to encode file using Base64 whose size is greater than 11kb

I am trying to send a file as attachment to an Account at salesforce.com using the Java Api. The problem I am facing is that when I send a file of less then 11kb as encoded in base64 it works OK but when I send a file larger than 11K, the file is end to the server but not properly i.e. all bytes of the file are not send. Can there be any problem with the Base64 class or else. Also salesforce api requires files to be send encoded in Base64, so is there any other way to it then the one method I have used in the following code?

 

File f = new File("Abc.wav");

FileInputStream fis = new FileInputStream(f);

 

byte[] data  = new byte[f.length()];

fis.read(data);

 

String s = org.apache.axis.encoding.Base64.encode(data);

SuperfellSuperfell
fis.read is not required to fill the byte array you pass it, so you need to keep calling read until you've filled the entire byte array.