Skip to content

How to read form parameters with helidon-se 4? #7915

Answered by romain-grecourt
sixwaaaay asked this question in Q&A
Discussion options

You must be logged in to vote

Form parameters can be processed like this:

Parameters parameters = request.content().as(Parameters.class);

E.g.

routing.post("/form-params", (req, res) -> {
    Parameters parameters = req.content().as(Parameters.class);
    res.send("value of 'foo': " + parameters.get("foo"));
})

Multipart can be processed like this:

MultiPart mp = req.content().as(MultiPart.class);

E.g.

routing.post("/multipart", (req, res) -> {
      MultiPart mp = req.content().as(MultiPart.class);
      while (mp.hasNext()) {
          ReadablePart part = mp.next();
          if ("file[]".equals(part.name())) {
              try (InputStream in = part.inputStream()) {
                  // ...
              } catch (I…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by sixwaaaay
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants