@Override
    public EueWriteFeature.Chunk upload(final Path file, Local local, final BandwidthThrottle throttle, final StreamListener listener,
                                        final TransferStatus status, final ConnectionCallback prompt) throws BackgroundException {
        if(status.getLength() >= threshold) {
            if(Vault.DISABLED == registry.find(session, file)) {
                // Only allow concurrent write of chunks when not uploading to vault. Write with default feature multiple 4MB chunks in parallel
                return new EueLargeUploadService(session, fileid, writer).upload(file, local, throttle, listener, status, prompt);
            }
            // Write with multipart write feature for known file length sequentially 4MB chunks
            return new EueUploadService(session, fileid, writer).upload(file, local, throttle, listener, status, prompt);
        }
        // Write single chunk smaller than threshold
        return new EueSingleUploadService(session, fileid, writer).upload(file, local, throttle, listener, status, prompt);
    }
@Test
    public void testUploadSimpleFile() throws Exception {
        final EueResourceIdProvider fileid = new EueResourceIdProvider(session);
        final EueThresholdUploadService service = new EueThresholdUploadService(session, fileid, VaultRegistry.DISABLED);
        final Path container = new EueDirectoryFeature(session, fileid).mkdir(new Path(new AlphanumericRandomStringService().random(), EnumSet.of(AbstractPath.Type.directory)), new TransferStatus());
        final String name = new AlphanumericRandomStringService().random();
        final Path file = new Path(container, name, EnumSet.of(Path.Type.file));
        final Local local = new Local(System.getProperty("java.io.tmpdir"), name);
        final int length = 2881;
        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();
        service.upload(file, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), count, status, new DisabledConnectionCallback());
        assertEquals(content.length, count.getSent());
        assertTrue(status.isComplete());
        assertTrue(new EueFindFeature(session, fileid).find(file));
        assertEquals(content.length, new EueAttributesFinderFeature(session, fileid).find(file).getSize());
        final byte[] compare = new byte[length];
        IOUtils.readFully(new EueReadFeature(session, fileid).read(file, new TransferStatus().withLength(length), new DisabledConnectionCallback()), compare);
        assertArrayEquals(content, compare);
        new EueDeleteFeature(session, fileid).delete(Collections.singletonList(container), new DisabledLoginCallback(), new Delete.DisabledCallback());
        local.delete();
    }