I'm using apache client5 fluent, I need to save the MultipartEntity parameter log to the database

89 Views Asked by At
HttpEntity httpEntity = MultipartEntityBuilder.create()
                .addTextBody("name", "张三", ContentType.TEXT_PLAIN.withCharset(StandardCharsets.UTF_8))
                .addBinaryBody("file", new File("C:\\Users\\123\\Desktop\\QQ截图20231010143306.png"))
                .build();

        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        httpEntity.writeTo(byteArrayOutputStream);

        byte[] multipartByteArray = byteArrayOutputStream.toByteArray();
        // save multipartByteArray Log To Mysql

        Request.post("")
                .body(httpEntity);

I use httpEntity.writeTo() to turn MultipartEntity into byte[] and store it in mysql as a log record. So when I want to view all parameters in this MultipartEntity request, what method should I use? Or how to turn this byte into LinkedMultiValueMap<String, Part>?

0

There are 0 best solutions below