Need sftp client and use example

Hello
I am looking to use elixir to sftp client to connect to a server and list a directory to process.

I found sftp_client and sftp_ex clients that wrap erlang sftp .

Need some examples of connection and directory list… look for a file exists or not

Thanks and hope you all are well

Ok
I git oart way through.
I can list my files but am having an issue getting file file info for an individual file
bwflista =SFTP.AccessService.file_info(conn, fremote_path)

tried look at record structures, but haven’t had any luck

get this info
Protocol.UndefinedError) protocol Enumerable not implemented for {:ok, %File.Stat{access: :read, atime: {{2020, 8, 30}, {17, 45, 50}}, ctime: :undefined, gid: 0, inode: 0, links: 1, major_device: 0, minor_device: 0, mode: 33133, mtime: {{2020, 8, 30}, {17, 45, 50}}, size: 8723608, type: :regular, uid: 0}} of type Tuple

which is correct for the file

cant seem to access , what i think is a tuple.

any help appreciated

regards

Looks like you just need to pattern match on the return value of SFTP.AccessService.file_info

case SFTP.AccessService.file_info(conn, fremote_path) do
  {:ok, bwflista} -> # success, do something with bwflista
  {:error, reason} -> # handle error
end

Thanks
i used the following that seems to work
case SFTP.AccessService.file_info(conn, fremote_path) do
{:ok, bwflista} -> IO.inspect bwflista.atime # success, do something with bwflista
#{:error, reason} -> # handle error
end

found the IO.inspect on a post

Thanks for the help!!

Regards

1 Like