如何在Mule 4中将文件上传至Azure Blob容器内指定文件夹
解决Mule 4 Azure Storage连接器上传Blob到指定子路径的问题
Azure Blob存储本身没有物理文件夹结构,所谓的“文件夹”是通过Blob名称中的斜杠(/)来模拟的。要将文件上传到my-container/examples路径下,只需在fileName属性中添加examples/前缀即可。
修改后的XML配置如下:
<azure-storage:upload-blob doc:name="Upload Json" doc:id="63fa613e-b355-4b6f-9f81-4ddd8dd40998" config-ref="azure_storage_config"> <azure-storage:storblob container="my-container" fileStream="#[payload]" fileName="examples/file.json"/> </azure-storage:upload-blob>
关键说明
- 无需预先在Azure容器中创建
examples文件夹,上传带examples/前缀的Blob时,Azure会自动模拟出对应的文件夹结构。 - 如果需要动态指定路径(比如从变量读取),可以使用MEL表达式,示例:
fileName="#[vars.targetFolder]/file.json",其中vars.targetFolder是存储路径前缀的变量。
内容的提问来源于stack exchange,提问作者java12399900
相关产品推荐
相关产品推荐

