2.46.3.3. 处理 多部分/信息数据 文件上传
您可以通过列出特定文件扩展来限制上传到某些文件扩展:
from("platform-http:/upload/multipart?fileNameExtWhitelist=html,txt&httpMethodRestrict=POST") .to("log:multipart") .process(e -> { final AttachmentMessage am = e.getMessage(AttachmentMessage.class); if (am.hasAttachments()) { am.getAttachments().forEach((fileName, dataHandler) -> { try (InputStream in = dataHandler.getInputStream()) { // do something with the input stream } catch (IOException ioe) { throw new RuntimeException(ioe); } }); } });
from("platform-http:/upload/multipart?fileNameExtWhitelist=html,txt&httpMethodRestrict=POST")
.to("log:multipart")
.process(e -> {
final AttachmentMessage am = e.getMessage(AttachmentMessage.class);
if (am.hasAttachments()) {
am.getAttachments().forEach((fileName, dataHandler) -> {
try (InputStream in = dataHandler.getInputStream()) {
// do something with the input stream
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
});
}
});