@Override
    public Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback, final StreamListener listener) throws BackgroundException {
        try {
            final CopyFileRequest copy = new CopyFileRequest()
                .name(target.getName())
                .parentID(fileid.getFileId(target.getParent()))
                .mode(1); // Overwrite
            final File file = new FilesApi(session.getClient()).filesCopy(
                fileid.getFileId(source), copy);
            listener.sent(status.getLength());
            fileid.cache(target, file.getId());
            return target.withAttributes(new StoregateAttributesFinderFeature(session, fileid).toAttributes(file));
        }
        catch(ApiException e) {
            throw new StoregateExceptionMappingService(fileid).map("Cannot copy {0}", e, source);
        }
    }
@Test
    public void testCopyDirectoryServerSide() throws Exception {
        final StoregateIdProvider fileid = new StoregateIdProvider(session);
        final Path top = new StoregateDirectoryFeature(session, fileid).mkdir(new Path(
            String.format("/My files/%s", new AlphanumericRandomStringService().random()), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
        final Path directory = new StoregateDirectoryFeature(session, fileid).mkdir(new Path(top, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus());
        final String name = new AlphanumericRandomStringService().random();
        final TransferStatus status = new TransferStatus();
        final Path file = new StoregateTouchFeature(session, fileid).touch(new Path(directory, name, EnumSet.of(Path.Type.file)), status);
        final Path target_parent = new StoregateDirectoryFeature(session, fileid).mkdir(new Path(top, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus());
        final Path target = new Path(target_parent, directory.getName(), EnumSet.of(Path.Type.directory));
        final StoregateCopyFeature feature = new StoregateCopyFeature(session, fileid);
        assertTrue(feature.isSupported(directory, target));
        final Path copy = new StoregateCopyFeature(session, fileid).copy(directory, target, new TransferStatus(), new DisabledConnectionCallback(), new DisabledStreamListener());
        assertNotEquals(file.attributes().getFileId(), copy.attributes().getFileId());
        assertTrue(new DefaultFindFeature(session).find(file));
        assertTrue(new DefaultFindFeature(session).find(target));
        assertTrue(new DefaultFindFeature(session).find(copy));
        new StoregateDeleteFeature(session, fileid).delete(Collections.singletonList(top), new DisabledLoginCallback(), new Delete.DisabledCallback());
    }