@@ -13,7 +13,20 @@ the SFTP protocol using [asyncssh](https://github.com/ronf/asyncssh).
1313
1414## Tutorial
1515
16- Install the ` sshfs ` from PyPI or the conda-forge, and import it;
16+ Install the ` sshfs ` from PyPI or the conda-forge. This will install ` fsspec `
17+ and register ` sshfs ` for ` ssh:// ` urls, so you can open files using:
18+
19+ ``` py
20+ from fsspec import open
21+
22+ with open (' ssh://[user@]host[:port]/path/to/file' , " w" ) as file :
23+ file .write(" Hello World!" )
24+
25+ with open (' ssh://[user@]host[:port]/path/to/file' , " r" ) as file :
26+ print (file .read())
27+ ```
28+
29+ For more operations, you can use the ` SSHFileSystem ` class directly:
1730
1831``` py
1932from sshfs import SSHFileSystem
@@ -43,6 +56,8 @@ fs = SSHFileSystem(
4356)
4457```
4558
59+ Note: you can also pass ` client_keys ` as an argument to ` fsspec.open ` .
60+
4661All operations and their descriptions are specified [ here] ( https://filesystem-spec.readthedocs.io/en/latest/api.html#fsspec.spec.AbstractFileSystem ) .
4762Here are a few example calls you can make, starting with ` info() ` which allows you to retrieve the metadata about given path;
4863
@@ -61,15 +76,15 @@ You can also create new files through either putting a local file with `put_file
6176``` py
6277>> > with fs.open(' /tmp/message.dat' , ' wb' ) as stream:
6378... stream.write(b ' super secret messsage!' )
64- ...
79+ ...
6580```
6681
6782And either download it through ` get_file ` or simply read it on the fly with opening it;
6883
6984``` py
7085>> > with fs.open(' /tmp/message.dat' ) as stream:
7186... print (stream.read())
72- ...
87+ ...
7388b ' super secret messsage!'
7489```
7590
@@ -80,10 +95,10 @@ There are also a lot of other basic filesystem operations, such as `mkdir`, `tou
8095>> > fs.mkdir(' /tmp/dir/eggs' )
8196>> > fs.touch(' /tmp/dir/spam' )
8297>> > fs.touch(' /tmp/dir/eggs/quux' )
83- >> >
98+ >> >
8499>> > for file in fs.find(' /tmp/dir' ):
85100... print (file )
86- ...
101+ ...
87102/ tmp/ dir / eggs/ quux
88103/ tmp/ dir / spam
89104```
0 commit comments