Howto implement SFTP with Qt/QNetworkAccessManager (C++)

喜夏-厌秋 提交于 2019-12-03 12:16:03

问题


I'm new to Qt and I would like to implement FTP and SFTP support for my software. As I googled I discovered that there doesn't exist a sftp library for Qt but it should be possible with QNetworkAccessManager. I tried then to discover on how to build a custom protocol or something like that but didn't figure out how to do it.

Does someone know how I could do that?

Thanks, Michael


回答1:


There is no support for SFTP in Qt SDK but Qt Creator implements SFTP.

I have isolated the library that contains SSH and SFTP and I have created a new project named QSsh in Github. The aim of the project is to provide SSH and SFTP support for any Qt Application.

I have written an example on how to upload a file using SFTP. Take a look at examples/SecureUploader/

I hope it might be helpful




回答2:


You need a custom implementation for each protocol. But we can create a class like QHttp which will do that. There are several protocols that has similar semantic, but not all. So, if you want write it, tell me and I help you.




回答3:


There's no current SSH wrapper implementation in the Qt SDK. You have 3 choices here:

  1. Roll your own custom SSH/SFTP client implementation using the IETF RFC and standard drafts like RFC4253. This might not be what you're looking for.
  2. Use any of the ssh implementation libraries like openssh/libssh directly or writing your own Qt/C++ wrapper for future-reuse. Any reasonably decent project with ssh needs usually links to a an already established ssh library and uses it programatically. Like Qt Creator does, if you dig inside it long enough you'll find what user Paglian mentioned earlier. Relying on a library is less risky and more future-proof then rolling your own.
  3. Use openssh tooling at the command line interface directly, using QProcess just like you'd use it at the shell. This is is the fastest method if you're working on a proof-of-concept project and don't need any complex ftp operations, as it might get a bit difficult to devise a robust wrapper around the CLI tooling.


来源:https://stackoverflow.com/questions/6758121/howto-implement-sftp-with-qt-qnetworkaccessmanager-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!