Article
Yuri Marx · Sep 13 3m read

Create, List, Upload and Download network files and folders Using SMB Protocol and IRIS Interoperability

Samba is the standard for file services interoperability across Linux, Unix, DOS, Windows, OS/2 and other OS. Since 1992, Samba has provided secure, stable and fast file services for all clients (OS and programs) using the SMB/CIFS protocol. Network administrators have used SAMBA to create shared network folders to allow company employees to create, edit and view corporate files as if they were on their computers locally, when these files are physically located on a network file server. It is possible to create a network folder in Linux and see it as a shared folder in Windows, for example. 

Currently IRIS connectors do not support accessing and writing to remote files and folders using SMB protocol. So it is necessary to use FTP. But, now we have Python, which has the smbprotocol library (https://pypi.org/project/smbprotocol). Based on this library, an interoperability application (production) was created for listing, recording and deleting files and folders using the SMB protocol. Now, your IRIS applications can write or access network files easily. The application is called samba-iris-adapter (https://openexchange.intersystems.com/package/samba-iris-adapter).

 

Application installation

Installation: ZPM

1. Open IRIS Namespace with Interoperability Enabled. Open Terminal and call:

USER>zpm "install samba-iris-adapter"

Installation: Docker

1. Clone/git pull the repo into any local directory

$ git clone https://github.com/yurimarx/samba-iris-adapter.git

2. Open the terminal in this directory and run:

$ docker-compose build

3. Run the IRIS container with your project:

$ docker-compose up -d

How to Run the App

1. Go to the Interoperability > Configure > Credentials:

2. Set credentials and save with these values:

ID: SambaCredentials
User name: bob
Password: bobspasswd 
Credentials

3. Open the production http://localhost:52795/csp/user/EnsPortal.ProductionConfig.zen?PRODUCTION=dc.samba.SambaProduction and start it.

4. Go to your REST client app and use these REST operations (with basic auth and credentials _SYSTEM/SYS):

5. Create a new Remote Folder: POST http://localhost:52795/csp/samba/CreateFolder with JSON Body: {"Folder":"samplefolder"}

6. To Send a File to a Remote Folder: POST http://localhost:52795/csp/samba/CreateFile/samplefolder with form-data selected to send multipart file. The name of the multipart file is file and in value select any file from your computer, check this image with a example using postman:

7. List files inside a Remote Folder: GET http://localhost:52795/csp/samba/ListFilesIntoFolder/samplefolder:


8. Download the File: POST http://localhost:52795/csp/samba/DownloadFile with JSON Body: {"Folder":"samplefolder", "Filename":"cat.jpg"}:

9. See productions messages into http://localhost:52795/csp/user/EnsPortal.ProductionConfig.zen?$NAMESPACE=USER&$NAMESPACE=USER& > Messages tab > click the Session:

10. Check the new folder and file inside /mnt2 folder inside samba docker instance:

Enjoy!

3
2 218
Discussion (1)2
Log in or sign up to continue