How can I See the content of a MultipartForm request?

和自甴很熟 提交于 2019-12-04 01:09:22

Use the org.apache.http.entity.mime.MultipartEntity writeTo(java.io.OutputStream) method to write the content to an java.io.OutputStream, and then convert that stream to a String or byte[]:

// import java.io.ByteArrayOutputStream;
// import org.apache.http.entity.mime.MultipartEntity;
// ...
// MultipartEntity entity = ...;
// ...

ByteArrayOutputStream out = new ByteArrayOutputStream(entity.getContentLength());

// write content to stream
entity.writeTo(out);

// either convert stream to string
String string = out.toString();

// or convert stream to bytes
byte[] bytes = out.toByteArray();

Note: this only works for multipart entities both smaller than 2Gb, the maximum size of a byte array in Java, and small enough to be read into memory.

Do you not know the content? Although, you are building the StringBody by supplying sharedValue. So, how could it be different than sharedValue.

Dharma Sai Seerapu

I have printed the Multipart request by following code, You can try like

ByteArrayOutputStream bytes = new ByteArrayOutputStream();

entity.writeTo(bytes);

String content = bytes.toString();

Log.e("MultiPartEntityRequest:",content);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!