Mulesoft download file from url - opinion
Hi, @drewmace.
You'll have to use an HTTP Request connector and set it to request that URL, it will "download" it and you'll receive it through the output payload, and then you can proceed with your transformation.
I'll give you an example to hit a URL stored in the payload using the HTTP Request connector. Basically, I parse the URL through Dataweave and make the request, in this case, if you test that endpoint it will redirect your browser to the Salesforce Connector API doc, but the logic is pretty much the same.
<http:request-config name="HTTP_Request_Configuration" host="# [payload.host]" port="80" doc:name="HTTP Request Configuration"/>
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
<flow name="requestingurlFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
<set-payload value="# ["http://mulesoft.github.io/salesforce-connector/8.3.1/apidocs/apidoc.html"]" doc:name="Hardcoded URL"/>
<dw:transform-message doc:name="Transform Message">
<dw:input-payload doc:sample="sample_data/string.dwl"/>
<dw:set-payload><![CDATA[%dw 1.0
%output application/java
---
((payload replace "http:\/\/" with "") scan /([a-z].?)\/{1,1}?([a-z](\W\w*)*)/) map
{
"host":$[1],
"path":$[2]
} reduce $] ]></dw:set-payload>
</dw:transform-message>
<http:request config-ref="HTTP_Request_Configuration" path="/{path}" method="GET" doc:name="HTTP">
<http:request-builder>
<http:uri-param paramName="path" value="# [payload.path]"/>
</http:request-builder>
</http:request>
<logger level="INFO" doc:name="Logger"/>
</flow>
I hope it helps.
Regards.
-
-
-