Is it a good practice to combine different parameters in to a single entity part in a MultiPart call?

StackOverflow https://stackoverflow.com/questions/11004845

  •  14-06-2021
  •  | 
  •  

質問

In our project we are using the Multpart (http.entity.mime.MultipartEntity) to send data to the backend. Now, we have a new requirement which basically states the need to restrict the number of parts to two in a MultiPart request.

Normally, we added a new part for each parameter:

entity.addPart("parameterName1",new StringBody(parameterValue1));
entity.addPart("parameterName2",new StringBody(parameterValue2));
entity.addPart("parameterName3",new StringBody(parameterValue3));
entity.addPart("parameterName4",new StringBody(parameterValue4));

Now the requirement is like:

entity.addPart("parameterName1",new StringBody(parameterValue1+"|"+parameterValue2+"|"+parameterValue3));
entity.addPart("parameterName2",new StringBody(parameterValue2));

I would like to know if this is a good standard to follow and will this always restrict the number of parts to "two" in the Multipart call?

役に立ちましたか?

解決

I would not say restricting multipart request to only two or any specified number as best practice but you can do that, make sure that is not an practice, you might want to explore business case more to get clear understanding of the requirement.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top