简体   繁体   中英

UI monitoring using net-SFTP

I am developping an app and i need to download some files using sftp. I installed the gem net-sftp and its works fine. Using the monitoring process i've found on this page : http://net-ssh.rubyforge.org/sftp/v2/api/ , i can see the progress in my terminal. The thing is, i'ld like to let the user see what is going on during the process, showing a progress bar and maybe displaying a monitoring line in my user interface.

I have tried many things, but none of them work. When i enter the download loop, i can't modify any of my instance variables, so i can't save the monitoring data to display it with javascript. alter-filters doesn't work either.

I don't know how to store the information in the loop to use it in my UI. Any idea ?

I'm going to assume that you have something like this going on...

1. client ----> 'do sftp tranfer' ----> server
2.                                      server ------> 'doing sftp'
3. client <---- 'done sftp' ----------- server

The short answer would be that you can't easily give progress to the client in this situation.

The longer answer would be that you have to open some kind of stream with the client to send progress.

1. client ----> 'do sftp tranfer' ----> server    
2.                                      server ------> 'doing sftp'
3. client <====> 'open stream'    <===> server
4. client <---- 'OK' -----------        server

The trick here would be communicating between the two processes on the server that are doing the stream and the sftp. s

I'm about to jump into something similar, and I believe this will be my approach. I currently have the server accessing the location and downloading a file. While that's happening I will have the server check the file size of the file every ~ 5 seconds and report back the size. If you grab the file size and report that back before the download starts then you'll be able to provide progress I would think.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM