@@ -24,6 +24,29 @@ import Pkg;Pkg.add("SFTPClient")
2424
2525## SFTPClient Examples
2626
27+ Examples:
28+
29+ ```
30+ using SFTPClient
31+
32+ # Replace with your actual credentials
33+ username = "demo"
34+ password = "password"
35+ url = "sftp://test.rebex.net/pub/example/"
36+
37+ file_name = "readme.txt"
38+
39+ sftp = SFTP(url, username, password)
40+
41+ try
42+ SFTPClient.download(sftp, file_name;downloadDir=".")
43+ println("File downloaded successfully! $(file_name)")
44+ catch e
45+ println("Error downloading file: ", e)
46+ end
47+
48+ ```
49+
2750```
2851
2952 using SFTPClient
@@ -33,16 +56,52 @@ import Pkg;Pkg.add("SFTPClient")
3356 downloadDir="/tmp/"
3457 SFTPClient.download.(sftp, files, downloadDir=downloadDir)
3558
36- ```
59+ statStructs = sftpstat(sftp)
3760
61+ ```
62+
63+
64+
3865```
3966 #You can also use it like this
4067 df=DataFrame(CSV.File(SFTPClient.download(sftp, "/mydir/test.csv")))
68+ # For certificates you can use this for setting it up
69+ sftp = SFTP("sftp://mysitewhereIhaveACertificate.com", "myuser")
70+ # Since 0.3.8 you can also do this
71+ sftp = SFTP("sftp://mysitewhereIhaveACertificate.com", "myuser", "cert.pub", "cert.pem") # Assumes cert.pub and cert.pem is in your current path
72+ # The cert.pem is your certificate (private key), and the cert.pub can be obtained from the private key.
73+ # ssh-keygen -y -f ./cert.pem. Save the output into "cert.pub".
4174
42- # For certificate authentication, you can do this (since 0.3.8)
43- sftp = SFTP("sftp://mysitewhereIhaveACertificate.com", "myuser", "cert.pub", "cert.pem")
44-
45- # The cert.pem is your certificate (private key), and the cert.pub can be obtained from the private # key as following: ssh-keygen -y -f ./cert.pem. Save the output into "cert.pub".
75+ ```
76+
77+ Full example for working with JSON
4678
4779```
80+ using SFTPClient
81+ using DataFrames
82+ using JSON
83+
84+ # Replace with your actual credentials
85+ username = "username"
86+ password = "password"
87+ url = "sftp://myserver/directory/"
88+
89+ file_name = "wheat.json"
90+
91+ sftp = SFTP(url, username, password)
92+
93+ try
94+ SFTPClient.download(sftp, file_name;downloadDir=".")
95+ println("File downloaded successfully!")
96+ catch e
97+ println("Error downloading file: ", e)
98+ end
99+
100+ data = JSON.parsefile(file_name; null=missing, inttype=Float64)
101+
102+ # Convert JSON to DataFrame. The Tables.dictrowtable is necessary for any data which does not have fields for all data.
103+ wheatDF = DataFrame(Tables.dictrowtable(data))
104+
105+
48106
107+ ```
0 commit comments