@Override
    public FileEntity upload(final Path file, final Local local, final BandwidthThrottle throttle, final StreamListener listener, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException {
        if(status.getLength() > 0) {
            return new BrickUploadFeature(session, writer).upload(file, local, throttle, listener, status, callback);
        }
        else {
            new BrickTouchFeature(session).touch(file, status);
            return null;
        }
    }
@Test
    public void testUpload() throws Exception {
        final BrickThresholdUploadFeature feature = new BrickThresholdUploadFeature(session);
        final Path root = new Path("/", EnumSet.of(Path.Type.directory, Path.Type.volume));
        final String name = new AlphanumericRandomStringService().random();
        final Path test = new Path(root, name, EnumSet.of(Path.Type.file));
        final Local local = new Local(System.getProperty("java.io.tmpdir"), name);
        final int length = 254;
        final byte[] content = RandomUtils.nextBytes(length);
        IOUtils.write(content, local.getOutputStream(false));
        final TransferStatus status = new TransferStatus();
        status.setLength(content.length);
        final BytecountStreamListener count = new BytecountStreamListener();
        feature.upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED),
            count, status, new DisabledLoginCallback());
        assertEquals(content.length, count.getSent());
        assertTrue(status.isComplete());
        assertTrue(new BrickFindFeature(session).find(test));
        final PathAttributes attributes = new BrickAttributesFinderFeature(session).find(test);
        assertEquals(content.length, attributes.getSize());
        final byte[] compare = new byte[length];
        IOUtils.readFully(new BrickReadFeature(session).read(test, new TransferStatus().withLength(length), new DisabledConnectionCallback()), compare);
        assertArrayEquals(content, compare);
        new BrickDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
        local.delete();
    }