How can I connect to an FTPS server with Elixir or Erlang?

Hi, I am trying to connect to an FTPS server using elixir. My goal is to simply be able to upload/download files to/from specific directories. I have found a lot of information on FTP but not on FTPS. Are there any good libraries I can use to do FTPS in Elixir? If not, how do I get the Erlang :ftp module to connect with SSL/TLS? I’ve never used Erlang directly before so the documentation I found here is a little less than helpful."my.ftps.server", [what: "options", go: "here?"]

I didn’t do it so far, but after glancing over the docs, you need to provide tls: […], if the list is empty thats enough to active the TLS layer, but if you need to pass in options, you can find them in the :ssl.ssloption/0-type.

1 Like

Thanks, what confused me was the way the documentation was written then. I saw that part as well but I didn’t know how “tls_options()” was actually supposed to be written out. I’ll give it a shot tomorrow and update this post accordingly.

Since it’s an erlang module, I expect that you will need to use erlang strings (that in Elixir are charlists - note the single quotes) and therefore, using your example:'my.ftps.server', [what: 'options', go: 'here?']

Well spot! Thank you.

Yeah, those huge nested typespecs that the erlang documentation uses can be confusing at times… Especially if mentioned types are sometimes only locally scoped and sometimes global and sometimes remote, and linking is very bad between them. Its often manually drilling and hunting them down :frowning:.

1 Like

Update: For anyone else who may have this problem in the future @NobbZ answer worked for me. Here is a code snippet

host = ''
{username, password} = {'myUserName', 'S3cr3t5'}
directory = '/the/directory/which/has/the/file/I/want'
file_name = 'file_to_download.txt'

{:ok, ftp_client} =, [tls: []])
:ftp.user(ftp_client, username, password), directory)
{:ok, file_content} = :ftp.recv_bin(ftp_client, file_name)

Thanks for the code monkey. Three years later and still of value!

1 Like

Also of help putting ftp under applications in mix.exs

def application do
extra_applications: [:logger, :ftp]