@Override
    public boolean encode(InputStream data, OutputStream os) {
        byte[] buffer = ByteArrayPool.get().getBytes();
        try {
            int read;
            while ((read = data.read(buffer)) != -1) {
                    os.write(buffer, 0, read);
            }
            return true;
        } catch (IOException e) {
            if (Log.isLoggable(TAG, Log.DEBUG)) {
                Log.d(TAG, "Failed to encode data onto the OutputStream", e);
            }
            return false;
        } finally {
            ByteArrayPool.get().releaseBytes(buffer);
        }
    }
An {@link Encoder} that can write an {@link InputStream} to disk.
core/src/main/java/com/bumptech/glide/load/model/StreamEncoder.java