class FileEntityProvider implements EntityProvider<File> {

    @Override
    public File readFrom(Class<File> type,
                         Type genericType,
                         Annotation[] annotations,
                         MediaType mediaType,
                         MultivaluedMap<String, String> httpHeaders,
                         InputStream entityStream) throws IOException {
        File f = FileCollector.getInstance().createFile();
        try (OutputStream out = new FileOutputStream(f)) {
            ByteStreams.copy(entityStream, out);
        }
        return f;
    }

}