MaterialFiles icon indicating copy to clipboard operation
MaterialFiles copied to clipboard

Wrote a android sftp document provider using libssh2

Open aguaviva opened this issue 1 year ago • 4 comments

It works great with Material Files in general, the libssh2 is quite a solid and it allows me to do things the Material Files built-in SFTP won't do. For example I can stream movies from a Raspberry Pi I have in a different country :)

You are welcome to steal anything you want from my project, I wrote the java bindings and also some helper classes. I hope that helps somehow :)

A strange issue I found is that when visualizing a 12Mb picture, I noticed that when zooming in/out, the picture visualizer tries to reload the picture. Not sure if this is an issue or expected.

Anyway, thanks for your great app and I hope I can help in any way :)

aguaviva avatar Dec 14 '23 19:12 aguaviva

You are welcome to steal anything you want from my project, I wrote the java bindings and also some helper classes. I hope that helps somehow :)

Thanks, but I generally prefer JVM dependencies when possible, because native code is larger and segfaults are much more annoying than NPEs. The sshj library I'm using is working but somehow slow, and I don't think that's something intrinsic with JVM, more likely a library/config (e.g. window size?) problem, but I never had the time to figure out why (and I personally don't use SFTP).

If you publish your app that would help some users though.

A strange issue I found is that when visualizing a 12Mb picture, I noticed that when zooming in/out, the picture visualizer tries to reload the picture. Not sure if this is an issue or expected.

It is expected, large images are loaded with subsampling to avoid overflowing the graphics buffer, which means the app only decodes the region being displayed and only at the necessary resolution. When user zooms in/out the app will decode again accordingly.

zhanghai avatar Dec 15 '23 02:12 zhanghai

  • As for the segfaults, curl and php both use libssh2, so it should be quite battle tested. Also I havent seen any segfauls, not even in the beggining when I was abusing the lib by not using it properly.

  • As for SFTP, it is awesome, all you need is a Raspberry Pi with a USB SDD to have your own KISS cloud :)

  • To play nicely with the network I'd be nice to only reload the image when the person stops zooming.

aguaviva avatar Dec 16 '23 12:12 aguaviva

As for the segfaults, curl and php both use libssh2, so it should be quite battle tested. Also I havent seen any segfauls, not even in the beggining when I was abusing the lib by not using it properly.

Well, I'm actually using rclone. But bringing rclone into Material Files is a different topic.

To play nicely with the network I'd be nice to only reload the image when the person stops zooming.

You may contribute to the subsample-scaling-image-view library for this, which Material Files uses to load large images.

zhanghai avatar Dec 16 '23 14:12 zhanghai

I got mutiple roots working (one for each connection) and I am supporting EXTRA_INFO + async queryDocuments and queryChildDocuments. Thanks for supporting all this on your side, it made my job a pleasure!

aguaviva avatar Dec 16 '23 20:12 aguaviva