@Override
	public CollectionObject putItem(String path, InputStream content) throws ContentRepositoryException, IOException {

		try (BufferedInputStream in = new BufferedInputStream(content)) {

			in.mark(1);
			int c = in.read();
			in.reset();

			if (c >= 0) {
				File file = new File(rootDir, path);
				try (FileOutputStream fos = new FileOutputStream(file)) {
					IOUtils.copy(in, fos);
				}
				return createContentObject(file);
			} else {
				File newFolder = new File(rootDir, path);
				if (newFolder.exists()) {
					throw new ContentRepositoryException("Folder already exists. path=" + path);
				}
				if (!newFolder.mkdirs()) {
					throw new ContentRepositoryException("Folder creation failed. path=" + path);
				}
				return createFolderObject(newFolder);
			}

		}

	}