RAML with MultiPart
Lets build to build file upload with MultiPart, below is RAML
RAML
/testUpload:
post:
description: file upload to sftp
headers:
filePath:
description: sftp file path
type: string
body:
multipart/form-data:
properties:
fileName:
description: file name
type: string
fileContent:
description: file content
type: file
fileTypes: ['application/octet-stream']
responses:
200:
body:
application/json:
example: |
{
"message": "success"
}
The below is the structure how file content is received in mule runtime based on above RAML contract.
{
"parts": {
"fileName": {
"headers": {
"Content-Disposition": {
"name": "fileName",
"subtype": "form-data"
}
},
"content": "test.dat"
},
"fileContent": {
"headers": {
"Content-Disposition": {
"name": "fileContent",
"filename": "test.dat",
"subtype": "form-data"
},
"Content-Type": "application/octet-stream"
},
"content": "This is test "
}
}
}
Comments
Post a Comment