Multipart::file({ name: "myFile", path: "myClients.json", mime: "application/json", fileName: "partMyClients.json"})
file
|
DataWeave 2.2 is compatible and bundled with Mule 4.2. This version of Mule reached its End of Life on May 2, 2023, when Extended Support ended. Deployments of new applications to CloudHub that use this version of Mule are no longer allowed. Only in-place updates to applications are permitted. MuleSoft recommends that you upgrade to the latest version of Mule 4 that is in Standard Support so that your applications run with the latest fixes and security enhancements. |
file({| name: String, path: String, mime?: String, fileName?: String |})
Creates a MultipartPart data structure from a resource file.
This version of the file function accepts arguments as an array of objects
that use the parameter names as keys, for example:
Parameters
| Name | Description |
|---|---|
|
Array of objects that specifies:
|
Example
This example inserts file content from a MultipartPart into a Multipart
data structure. It uses the form function to create the Multipart
and uses file to create a part named myClient with JSON content from
an external file myClients.json. It also specifies partMyClients.json as
the value for to the filename parameter.
Source
%dw 2.0
import dw::module::Multipart
output multipart/form-data
var myClients = "myClients.json"
var myArgs = { name: "myFile", path: "myClients.json", mime: "application/json", * fileName: "partMyClients.json"}
---
Multipart::form([
Multipart::file(myArgs)
])
file(String, String, String, String)
Creates a MultipartPart data structure from a resource file.
This version of the file function accepts arguments in a comma-separated
list, for example:
Multipart::field("myFile", myClients, 'application/json', "partMyClients.json")
Parameters
| Name | Description |
|---|---|
|
Array of objects that specifies:
|
Example
This example inserts file content from a MultipartPart into a Multipart
data structure. It uses the form function to create the Multipart type
and uses file to create a part named myClient with JSON content from
an external file myClients.json. It also specifies partMyClients.json as
the value for to the filename parameter.
Source
%dw 2.0
import dw::module::Multipart
var myClients = "myClients.json"
output multipart/form-data
---
Multipart::form([
Multipart::file("myFile", myClients, 'application/json', "partMyClients.json")
])



