This content originally appeared on DEV Community and was authored by elliot
1. Add modue of SFTP
After adding module of SFTP, you'll see below maven dependency added in pom
<dependency>
<groupId>org.mule.connectors</groupId>
<artifactId>mule-sftp-connector</artifactId>
<version>2.5.1</version>
<classifier>mule-plugin</classifier>
</dependency>
2. Setup local sftp server by docker
This section is omitted; please refer to the following article for details:
install sftp server
3. Config sftp in yaml file
- yaml
sftp:
host: "127.0.0.1"
port: "2222"
username: "sftpuser"
password: "123456"
remotePath: "~/sftp"
4. Add SFTP in global element config properties
Here's xml code of it:
<sftp:config name="SFTP_Config" doc:name="SFTP Config" doc:id="8217af71-2499-4cc2-9506-b81ab62b0e21" >
<sftp:connection host="${sftp.host}" port="${sftp.port}" username="${sftp.username}" password="${sftp.password}" workingDir="/"/>
</sftp:config>
5. Drag and drop an SFTP write processor and config it
Here's xml code of it:
<sftp:write doc:name="Write" doc:id="40143955-915c-4a62-8aeb-c65f8fb344b8" config-ref="SFTP_Config" path="/upload/test2.txt"/>
6. Use Bruno & FileZilla to verify the program
- Bruno
- FileZilla
After requesting successfully in bruno, you'll see below result in FileZilla:
Download the file from FileZilla, and the content of the file should be like this:
{
"ftpHost": "127.0.0.1",
"ftpPort": 2222,
"username": "sftpuser",
"password": "sftppass",
"remotePath": "/uploads",
"fileName": "local-test.txt",
"fileContent": "SGVsbG8gTG9jYWxTdG9yZSE="
}
This content originally appeared on DEV Community and was authored by elliot
elliot | Sciencx (2025-11-06T06:35:27+00:00) MuleSoft – SFTP – Write content to file and upload to server. Retrieved from https://www.scien.cx/2025/11/06/mulesoft-sftp-write-content-to-file-and-upload-to-server/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.




