int i = 0;
for(String key: files.keySet()) {
VirtualFile virtualFile = files.get(key);
parts.add(new StringPart("name", key));
parts.add(new StringPart("json", "{\"parameter\":{\"name\":\"" + key + "\",\"file\":\""+ String.format("file%d", i) +"\"}}"));
parts.add(new FilePart(String.format("file%d", i), new VirtualFilePartSource(virtualFile)));
i++;
}
post.setRequestEntity(new MultipartRequestEntity(parts.toArray(new Part[parts.size()]), post.getParams()));
files.clear();
}