Sftp client with anvil

Good evening all,

I just want to quickly share sample project. This project is an sftp client which uses a library called pysftp, where you can browse the root directory for all files and folders. You can also upload, download and remove files within the root directory.

Feel free to test the app live https://sftpclient.anvil.app
(I have set up a dummy sftp server which the app is connected to)

To speed up the app (make calls end responses to the sftp server faster) i guess that you should use a “persistent server”, where the sftp client object is only created once at the server side (i think so at least).

EDIT, there are still some ui tweaks on mobile that have to be done :slight_smile:

If you plan to clone the project, you need a “full python server”. So you need > Personal Plan.
This can be activated in: Settings => Python versions => Under python versions and packages, choose python 3.10 (beta).
After this has been done you also need to Add the pysftp package located within the same page.

Link to project https://anvil.works/build#clone:5MHM54WUTRF6PKBV=APTOUVMQUAOFE7KTD4DIKHXZ

(And yes, i have hardcoded an exposed all the credentials. If someone messes around too much i will just shut down the server :slight_smile: )

Happy hacking!

PS I welcome any feedback :slight_smile:

6 Likes

Very nice! And, given how much sftp still goes on within the finance sector, I may well have a use for that.

2 Likes

Hello. Sorry for bringing this old post back to life.
I have a question, probably due to my beginner status in programming.
I cloned the app and connected it to a temporary SFTP service; it works perfectly. Thank you very much, @tobias.carlbom .
Is there any way to achieve the same functionality from the client side, that is,
preventing the files to be uploaded from going through Anvil first before being sent to the FTP server?
I’m asking because I’m not sure whether Anvil imposes any traffic limits, and also to make it faster.
I’m working on a project that involves FTP management and running some processes, and I love being able to interact with the FTP server from the same app while also adding other features.
I’d rather implement a web service than distribute a desktop application.
So that’s my question: would it be feasible to implement this solution if all traffic necessarily has to pass through the Anvil server? thanks !!

ok, so SFTP basically uses SSH, which needs some kind of cryptography package to use on any system you want to use it from.
The “client” runs entirely on someone elses computer, so creating a cryptographically secure link from their computer to an SFTP server is usually done by connecting sockets and lots of low level bare metal access software.

Is it possible to do entirely in a browser? I mean sure**, but you are probably not going to find that someone has already solved the problem for you. 99% of the time if you are looking at SFTP in a browser, the browser is an interface for another server somewhere, just like anvil, but sometimes the server just runs on the persons local PC and the web browser connects to the local server running a cryptography package.

** (if you can make the browser run doom, you can probably build an SSH socket interface, but people are more enthusiastic about doom than SFTP)

If you are worried about anvil having the files or running out of space / bandwidth, you could run another service on another computer using uplink and have that other server get called directly from the client, which then in turn runs the SFTP software in python.

If your files are large make sure you are using a media object.

Thank you very much for your response.
Hahaha… I also prefer DOOM.

In the end, we’ll simplify the application: file handling will be done with FileZilla, and process launching and logging with ANVIL.

Best regards!!