Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for multipart field in HTTP output client #1087

Merged

Conversation

YachikaRalhan
Copy link
Contributor

With multipart support, we can divide a single batch of message into multiple HTTP request parts and send the POST request.
No need of having multiple messages to create a multipart request. Each part of the request will have its own headers and the fields of multipart array support interpolation
A sample benthos config for the same: set the parts in the bloblang pipeline and refer those in data of multipart

pipeline:
  processors:
    - bloblang: |
        meta AttachmentName = filename
        root.part1 = "ABC"
        root.part2 = "XYZ"

output:
  http_client:
    headers:
      Content-Type: multipart/form-data
    url: ""
    verb: POST
    multipart:
      - content_disposition: form-data; name="bin"; filename='${! meta("AttachmentName")
        content_type: application/bin
        body: ${! json("part2") }
      - content_disposition: form-data; name="data"
        content_type: application/json; charset=utf-8
        body: ${! json("part1") }

Note: this is only valid for HTTP output client

@Jeffail
Copy link
Member

Jeffail commented Jan 28, 2022

Ace, thanks @YachikaRalhan this looks great.

@Jeffail Jeffail merged commit 0a453b4 into benthosdev:master Jan 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants