https://iotflows.com
npm install @iotflows/iotflows-remote-access-clienthttps://iotflows.com
IoTFlow node.js client for remote SSL SFTP.
This application allows your webapp to securely transfer and manage files on your device behind NATs and firewalls.
Prerequisites:
You need to have:
1) An account in IoTFlows Console
2) IoTFlows Remote Access installed on your device
3) Enabled the SSL SSH tunnel in IoTFlows Console
Install the IoTFlows Remote Access Client via: npm install @iotflows/iotflows-remote-access-client
Configure the client:
``javascript
IoTFlowsRemoteAccessClient = require('@iotflows/iotflows-remote-access-client');
let client = new IoTFlowsRemoteAccessClient({
host: 'sX.devices.iotflows.com', //server name provided by IoTFlows Console when enabling SSH e.g. s2.devices.iotflows.com
device_uuid: 'dev_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', // device_uuid of your device in IoTFlows Console
device_username: 'username', // username of your device
device_password: 'password' // password of your device
})
`
Use a sftp command e.g. list the /etc/ folder:
`javascript`
client.sftp_with_ssl_proxy()
.then(sftp => {
sftp.list('/etc/').then(data => {
console.log(data)
sftp.end()
})
.catch(err => console.log(err))
})
.catch(err => console.log(err))
This package uses the ssh2-sftp-client commands:
`javascript
list(remoteFilePath: string, pattern?: string | RegExp): Promise
exists(remotePath: string): Promise
stat(remotePath: string): Promise
realPath(remotePath: string): Promise
get(
path: string,
dst?: string | NodeJS.WritableStream,
options?: sftp.GetTransferOptions,
): Promise
fastGet(remoteFilePath: string, localPath: string, options?: sftp.FastGetTransferOptions): Promise
put(
input: string | Buffer | NodeJS.ReadableStream,
remoteFilePath: string,
options?: sftp.TransferOptions,
): Promise
fastPut(localPath: string, remoteFilePath: string, options?: sftp.FastPutTransferOptions): Promise
cwd(): Promise
mkdir(remoteFilePath: string, recursive?: boolean): Promise
rmdir(remoteFilePath: string, recursive?: boolean): Promise
delete(remoteFilePath: string): Promise
rename(remoteSourcePath: string, remoteDestPath: string): Promise
chmod(remotePath: string, mode: number | string): Promise
append(input: Buffer | NodeJS.ReadableStream, remotePath: string, options?: sftp.TransferOptions): Promise
uploadDir(srcDir: string, destDir: string): Promise
downloadDir(srcDir: string, destDir: string): Promise
end(): Promise
on(event: string, callback: (...args: any[]) => void): void;
removeListener(event: string, callback: (...args: any[]) => void): void;
posixRename(fromPath: string, toPath: string): Promise
``