[Back to LOC CLI Guidebook](https://hackmd.io/4LIsNIuWQnuR70JMeuBAEA?view) [Setup LOC CLI Environment](https://hackmd.io/igLh4azUT2aI8Fv-q-0e-g) [Getting Started - JavaScript](https://hackmd.io/IiHvmAtjTTGFfakaH0dWuw?view) [Getting Started - TypeScript](https://hackmd.io/kz93Th7vTCCbO3GFxp3r-A) [LOC CLI Commands](https://hackmd.io/R4mrz2t1QSyTCHH73_2itg) [Local Simple Runtime Execution](https://hackmd.io/JhAMB49rS4CrpNdhHed7YA?view) # Local FTP Testing with Simple Runtime Here we will use [Pure-FTPd](https://www.pureftpd.org/project/pure-ftpd/) to run a local FTP server so that we can test the [file storage agent](https://hackmd.io/Uj-tC7l9Q82VyGr8R5PL2Q?view#File-Storage). ## Modify ```saffron-evenstore.yaml``` See [Local Simple Runtime Execution](https://hackmd.io/JhAMB49rS4CrpNdhHed7YA?view) for more information. ```yaml services: ... ftpd_server: image: stilliard/pure-ftpd restart: "always" container_name: pure-ftpd environment: PUBLICHOST: "127.0.0.1" FTP_USER_NAME: admin FTP_USER_PASS: "1234" FTP_USER_HOME: /home/admin volumes: - "./ftp:/home/admin/" ports: - "21:21" - "30000-30009:30000-30009" networks: - saffron ``` - FTP host: 127.0.0.1 - FTP port: 21 - FTP default user: admin - FTP password: 1234 ## Add ```/ftp``` and Test Files Add a ```/ftp``` directory under your FST workspace dir and put at least one text file in it. ```/ftp``` will be mounted as the FTP dir. ## Startup FTP Server Open a new terminal under the LOC CLI workspace dir and run the following command: ```bash docker-compose -f saffron-evenstore.yaml up -d ``` ## Add FTP Connection Variables in Profile For safety reasons, we'll put the connection information in the profile ([local.yaml](https://hackmd.io/JhAMB49rS4CrpNdhHed7YA?view#Create-Local-Profile) in our example): ```yaml # docker mode (host network) simpleRuntime: image: public.ecr.aws/m0s8j1u6/saffron/simple-runtime:release-0.5.1 dockerNetwork: host eventstoreEndpoint: http://127.0.0.1:8087 etcdEndpoints: http://127.0.0.1:2379 # FTP connection info ftp_host: 127.0.0.1 ftp_port: 21 ftp_user: admin ftp_pass: "1234" ``` Now update your profile: ```bash loc profile set -f local.yaml -p local ``` ## Get a File in Data Process ```javascript export async function run(ctx) { const filename = "test.txt"; const user = process.env.ftp_user; const pass = process.env.ftp_pass; const host = process.env.ftp_host; const port = process.env.ftp_port; // FTP url const url = `ftp://${user}:${pass}@${host}:${port}/${filename}`; const encodedData = await ctx.agents.fileStorage.simpleGet(url); const data = new TextDecoder().decode(encodedData); // content of the text file ctx.agents.logging.info(data); } ``` ###### tags: `LOC CLI`