简体   繁体   English

如何接受来自邮递员的任何多部分文件(图像/pdf/csv)并将相同的文件创建到 Mule 4 中的 SFTP 位置?

[英]How to accept any multipart file (image/pdf/csv) from postman and create the same file into SFTP location in Mule 4?

When I tried this usecase for some MIME types the content is coming in payload.parts[0].content, for some MIME types the content is coming in payload.parts.file.content.当我针对某些 MIME 类型尝试此用例时,内容出现在 payload.parts[0].content 中,对于某些 MIME 类型,内容出现在 payload.parts.file.content 中。 How to create the file in the same MIME type as how we received from postman in SFTP?如何创建与我们在 SFTP 中从邮递员那里接收到的 MIME 类型相同的文件?

Quite not sure in what ways you have used and tested the both expression.不确定您以何种方式使用和测试了这两个表达式。 Please find the screenshot below.请找到下面的屏幕截图。 I have added different format of datas in single request.我在单个请求中添加了不同格式的数据。 If you use mutiple format in single request and wanting to extract individually.如果您在单个请求中使用多种格式并希望单独提取。 Use payload.parts[0].content and payload.parts[1].content使用payload.parts[0].contentpayload.parts[1].content

Note: This expression ideally mean whatever you add (form-data) in postman body request can be extract using index.注意:理想情况下,此表达式意味着您在邮递员正文请求中添加的任何内容(表单数据)都可以使用索引提取。 Example: if you have added content-type: application/xml in the below picture 3rd row, should be using payload.parts[2].content示例:如果您在下图第 3 行添加了 content-type: application/xml,则应使用payload.parts[2].content

If you're using single request payload.parts.file.content can be used.如果您使用单个请求,则可以使用payload.parts.file.content

Once after the request reached HTTP/HTTPS ( source listener), use dataweave as below to convert binary in to the defined structure data一旦请求到达HTTP/HTTPS (源侦听器),使用如下的 dataweave 将二进制转换为定义的结构数据

%dw 2.0
output multipart/form-data
---
payload

After extracting the contents using the expressions, you can write in to SFTP (Screenshot) here I have stored in Vars (based on your logic)使用表达式提取内容后,您可以在此处写入SFTP(截图)我已存储在Vars (根据您的逻辑)

在此处输入图片说明

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM