class B2DirectoryFeature implements Directory<BaseB2Response> {

    @Override
    public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException {
        try {
            if(containerService.isContainer(folder)) {
                final B2BucketResponse response = session.getClient().createBucket(containerService.getContainer(folder).getName(),
                    null == region ? BucketType.valueOf(PreferencesFactory.get().getProperty("b2.bucket.acl.default")) : BucketType.valueOf(region));
                switch(response.getBucketType()) {
                    case allPublic:
                        folder.attributes().setAcl(new Acl(new Acl.GroupUser(Acl.GroupUser.EVERYONE, false), new Acl.Role(Acl.Role.READ)));
                }
                return new Path(folder.getParent(), folder.getName(), folder.getType(),
                    new PathAttributes(folder.attributes()));
            }
            else {
                status.setChecksum(writer.checksum(folder, status).compute(new NullInputStream(0L), status));
                status.setMime(MimeTypeService.DEFAULT_CONTENT_TYPE);
                final StatusOutputStream<BaseB2Response> out = writer.write(folder, status, new DisabledConnectionCallback());
                new DefaultStreamCloser().close(out);
                final EnumSet<Path.Type> type = EnumSet.copyOf(folder.getType());
                type.add(Path.Type.placeholder);
                return new Path(folder.getParent(), folder.getName(), type,
                    new B2AttributesFinderFeature(session, fileid).toAttributes((B2FileResponse) out.getStatus()));
            }
        }
        catch(B2ApiException e) {
            throw new B2ExceptionMappingService().map("Cannot create folder {0}", e, folder);
        }
        catch(IOException e) {
            throw new DefaultIOExceptionMappingService().map(e);
        }
    }

    public  B2DirectoryFeature(final B2Session session, final B2FileidProvider fileid);
    public  B2DirectoryFeature(final B2Session session, final B2FileidProvider fileid, final B2WriteFeature writer);

}