---
schema_version: "1"
id: 22767c73dcc528a54a4c388098d1f712bab6cb59066359804b81b0913a165cb8
title: Work with Multipart Data
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.4/dataweave-cookbook-work-with-multipart-data.md
canonical_url: https://docs.mulesoft.com/dataweave/2.4/dataweave-cookbook-work-with-multipart-data
source_site: docs.mulesoft.com
content_type: documentation
content_hash: cc21c687e47396127e4caaf3ef854fe9492bd3e5ba201121d124f324010a7ad2
description: MuleSoft Documentation Site
release: "2.4"
latest: false
---
---
product: DataWeave
version: 2.4
keywords: studio, anypoint, transform, transformer, format, xml, metadata, dataweave, data weave, datamapper, dwl, dfl, dw, output structure, input structure, map, mapping, date, time
---

# Work with Multipart Data

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

The following example iterates over a multipart payload and extracts data from each part.

The example uses the following functions:

- `read` (in the script’s header) reads the multipart content from a `multi` variable that sets the
  boundary to `34b21`.

- `mapObject` iterates over the parts in the multipart data returned by `read` and returns the index
  and `name` key of each part within a JSON object.

DataWeave Script:

```dataweave
%dw 2.0
output application/json
var multi = '--34b21
Content-Disposition: form-data; name="text"
Content-Type: text/plain

Book
--34b21
Content-Disposition: form-data; name="file1"; filename="a.json"
Content-Type: application/json

{
  "title": "Java 8 in Action",
  "author": "Mario Fusco",
  "year": 2014
}
--34b21
Content-Disposition: form-data; name="file2"; filename="a.html"
Content-Type: text/html

<!DOCTYPE html>
<title>
  Available for download!
</title>
--34b21--'
var parsed = read(multi, "multipart/form-data", {boundary:'34b21'})
---
parsed.parts mapObject ((value, key, index) -> {(index): key})
```

Output:

```json
{
  "0": "text",
  "1": "file1",
  "2": "file2"
}
```

For additional examples, see [Multipart Format (Form Data)](https://docs.mulesoft.com/dataweave/2.4/dataweave-formats-multipart#examples)
examples and functions referenced in [Multipart (dw::module::Multipart)](https://docs.mulesoft.com/dataweave/2.4/dw-multipart).

## See Also

- [DataWeave Selectors](https://docs.mulesoft.com/dataweave/2.4/dataweave-selectors)

- [DataWeave Cookbook](https://docs.mulesoft.com/dataweave/2.4/dataweave-cookbook)
