How To Read And Write Files On A Network Drive With An SMB Connector

Author: Saddam Shaikh

In this article, we will check how to read files from a network drive and write a file to a network drive.

What is SMB?

The Server Message Block Protocol (SMB protocol) is a network file sharing protocol to access remote files. It is used for sharing files, printers, serial ports, and other resources on share/network drive. Using this protocol, we can communicate with any server that is configured to receive an SMB client request.

By default, SMB protocol is disabled on Windows. Check the article to enable SMB protocol on Windows.

Prerequisite:

  • Anypoint Platform Account.
  • Anypoint Studio 7.6 or later.
  • SMB share and its authentication credentials. I have created SMB as a shared drive for this integration.
SMB share snapshot
Let’s start with Integration

Follow the below steps to read & write files from/to SMB share:

1. Download SMB Connector from Exchange. (Version = 3.0.1)

2. Add SMB Connector Config in Global Elements. Configure below parameters.

Domain: Enter the Windows domain for the user to log in with
Host: Hostname of server hosting a shared drive
Share: The named path of shared drive
Username: Enter the username to login
Password: Enter the corresponding password
File age: Minimum age of file to perform the operation

SMB Connector Configuration

3. Perform a Test Connection to make sure connection details are correct.

Test Connection Result

4. Read a file from a shared drive using SMB File Read operation. Refer to the below File Read configuration.

SMB File Read Operation Configuration

Test SMB file read flow using Postman. Output MIME Type is “application/octet-stream”.

SMB file.csv file content
File Read Operation Postman Snapshot

5. Write a file to the network drive using SMB File Write operation. Refer below File Write configuration.

SMB File Write Operation Configuration

Test SMB file write flow using Postman.

File Write Operation Postman Snapshot
SMB share snapshot after writing release.txt file

Hope, this article helps you. Thanks for reading.

References:

https://www.mulesoft.com/exchange/com.mulesoft.connectors/mule-smb-connector/

We use cookies on this site to enhance your user experience. For a complete overview of how we use cookies, please see our privacy policy.