Multipart::file({ name: "myFile", path: "myClients.json", mime: "application/json", fileName: "partMyClients.json"})
file
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")
])