 <p><code>Base64</code> encoding takes 3 input bytes and converts them to 4 bytes. So if you have 100 Mb file that will end up to be 133 Mb in <code>Base64</code>. When you convert it to Java string (<code>UTF-16</code>) it size will be doubled. Not to mention that during conversion process at some point you will hold multiple copies in memory. No matter how you turn this it is hardly going to work. </p> <p>This is slightly more optimized code that uses <code>Base64OutputStream</code> and will need less memory than your code, but I would not hold my breath. My advice would be to improve that code further by skipping conversion to string, and using temporary file stream as output instead of <code>ByteArrayOutputStream</code>.</p> <pre><code>InputStream inputStream = null;//You can get an inputStream using any IO API inputStream = new FileInputStream(file.getAbsolutePath()); byte[] buffer = new byte[8192]; int bytesRead; ByteArrayOutputStream output = new ByteArrayOutputStream(); Base64OutputStream output64 = new Base64OutputStream(output, Base64.DEFAULT); try { while ((bytesRead = inputStream.read(buffer)) != -1) { output64.write(buffer, 0, bytesRead); } } catch (IOException e) { e.printStackTrace(); } output64.close(); attachedFile = output.toString(); </code></pre>