title: Out of Memory Issue when encode into base64 video file
body: <p>I am trying to upload the video file into server with convert into base64. But I am getting out of memory exception even size is 2 mb also. How to resolve this issue. Please help me to over out, much appreciate your help.</p>
  
  <p>Here what I am doing</p>
  
  <pre><code>  byte [] ba = convertByteArray(videoUri);
  String baseimage=Base64.encodeToString(ba, Base64.NO_WRAP);
  
   public byte[] convertByteArray(Uri videoUri){
  
           InputStream iStream=null;
           byte[] inputData=null;
          try {
              iStream = getContentResolver().openInputStream(videoUri);
              inputData = getBytes(iStream);
  
          } catch (FileNotFoundException e) {
              e.printStackTrace();
          }
          catch (IOException e) {
              e.printStackTrace();
          }
  
  
          return inputData;
       }
  
       public byte[] getBytes(InputStream inputStream) throws IOException {
            ByteArrayOutputStream byteBuffer = new ByteArrayOutputStream();
            int bufferSize = 1024;
            byte[] buffer = new byte[bufferSize];
  
            int len = 0;
            while ((len = inputStream.read(buffer)) != -1) {
              byteBuffer.write(buffer, 0, len);
            }
            return byteBuffer.toByteArray();
          }
  </code></pre>