Send File as a parameter to a REST Service, from a client?

后端 未结 2 424
感情败类
感情败类 2021-02-10 18:34

My Requirement is to send the file to the REST Service through one client. That service is going to process the file. I am using Jersey API for implementing this. But I have sea

2条回答
  •  臣服心动
    2021-02-10 19:25

    Am I right by assuming, since its a MimeMultipart type, that I could not just send one, but multiple files or additional information maybe as String or whatever, on doing only one simple post, just by adding multiple MimeBodyParts containing the different files or whatever? for example like:

    final MimeMultipart request = new MimeMultipart();
    request.addBodyPart(new MimeBodyPart(new FileInputStream(new File(
        fileOne))), 0);
    request.addBodyPart(new MimeBodyPart(new FileInputStream(new File(
        fileTwo))), 1);
    

    etc.

提交回复
热议问题