I have a SFTP server hosting some files. How to hit my SFTP server from Catalyst and upload the files to Catalyst filestore?
1. Create a catalyst project and initialize the project in your local machine. You can refer to the help documentation for the same
here.
2. Install Catalyst CLI in order to work with Catalyst in your local machine.
You can refer to the help documentation for the same here.2. Create an advancedIO function from the Catalyst CLI while initializing the project.
3. Navigate to your function directory(~/{project_name}/functions/{function_name}) in your terminal
4. Install the necessary npm packages that are used in the function by executing the commands below
- npm install ssh2-sftp-client
5. Paste the given code. Modify your hostname, port number, username and password. Navigate back to your project directory.
- "use strict";
- const Client = require('ssh2-sftp-client');
- module.exports = async(req, res) => {
- connectToSFTPServer();
- res.write("hit");
- res.end();
- };
- async function connectToSFTPServer() {
- const sftp = new Client();
- const remoteHost = ''; //replace your SFTP host
- const remotePort = ; //replace your port number (default is 22 for SFTP)
- const remoteUsername = ''; //replace your SFTP server username
- const remotePassword = ''; //replace your SFTP server password
-
- try {
- await sftp.connect({
- host: remoteHost,
- port: remotePort,
- username: remoteUsername,
- password: remotePassword
- });
- console.log('Connected to SFTP server');
- // Perform SFTP operations here
- const remoteFilePath = '{your_remote_path}';
- const files = await getFilesInDirectory(sftp, remoteFilePath);
- console.log('Files in the remote directory:');
- files.forEach((file) => {
- console.log(file);
- });
- // Disconnect from the SFTP server
- await sftp.end();
- console.log('Disconnected from SFTP server');
- } catch (err) {
- console.error('Error:', err.message);
- }}
- async function getFilesInDirectory(client, remotePath) {
- const entries = await client.list(remotePath);
- const files = [];
- for (const entry of entries) {
- if (entry.type === 'd') {
- // If the entry is a directory, recursively call the function
- const subdirectoryPath = `${remotePath}/${entry.name}`;
- const subdirectoryFiles = await getFilesInDirectory(client, subdirectoryPath);
- files.push(...subdirectoryFiles);
- } else if (entry.type === '-') {
- // If the entry is a regular file, add it to the files array
- files.push(entry.name);
- }}
- return files;
- }
6. Run catalyst serve in order to test your function in local debugging.
7. Run catalyst deploy in order to deploy your function to the development environment. You can hit your function by using the URL generated while deploying the function. You can refer the help documentation for the same here.
Announcements
Introducing Catalyst 3.0: The agent-ready full-stack cloud!
Hi everyone! Catalyst 3.0 is here, bringing a major shift in how you can build and ship applications on Catalyst. With MCP connectors, agent skills, native agent plugins, a non-interactive CLI, zero egress, and 30+ services unified on one platform, Catalyst
[Webinar] Build smarter HR - Payroll Automation
If your HR and payroll teams are still relying on manual exports, spreadsheet reconciliations, or constant back-and-forth coordination to keep employee data aligned, this session is for you. We’re hosting a live webinar featuring Kyle Ferrara , CTO of
[Webinar] How Raptee.HV accelerates its EV platform
Curious about how EV platforms work behind the scenes? What does it actually take to run an EV platform from onboarding users to managing connected vehicles and deploying updates seamlessly? In this session, Raptee.HV shares how their platform is built
[Webinar] Deploy Docker apps with AppSail's custom runtime | Feb. 19
Hi everyone, Join us on February 19, 2026 at 8–9 PM IST for a live Catalyst webinar demonstrating how to deploy OCI-compliant Docker images with AppSail's custom runtime. You’ll learn how to: Package your apps as Docker containers Deploy via CLI or connect
Catalyst backs Vite.js!
Hi everyone, We're happy to support the open-source ecosystem that powers modern web development! If you’re building apps with Vite, Catalyst Slate is your go-to platform to deploy blazing-fast frontend apps with ease, scalability, and zero infrastructure