public void putFile(String name, InputStream rawBytes) throws IOException {
        if (name.endsWith(SLASH_EMPTY_DIRECTORY_SENTINEL)) {
            File dir = new File(mRootDirectory, name).getParentFile();
            if (dir == null) {
                throw new IOException("Empty root directory???");
            }
            if (!dir.exists() || !dir.isDirectory()) {
                if (!dir.mkdir()) {
                    throw new IOException(String.format("Couldn't make directory: %s", dir));
                }
            }
            return;
        }

        File file = new File(mRootDirectory, name);
        File parent = file.getParentFile();
        if (!parent.exists() || !parent.isDirectory()) {
            if (!parent.mkdirs()) {
                throw new IOException(String.format("Couldn't make directory: %s", parent));
            }
        }
        OutputStream outputStream = null;
        try {
            outputStream = new FileOutputStream(new File(mRootDirectory, name));
        } finally {
            if (outputStream == null) {
                rawBytes.close(); // I.e. in the process of throwing.
            }
        }
        IOUtil.copyAndClose(rawBytes, outputStream);
    }