monkeypy

monkeypy

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 http://erlang.org/doc/man/ftp.html#open-2 is a little less than helpful.

:ftp.open("my.ftps.server", [what: "options", go: "here?"]

Marked As Solved

NobbZ

NobbZ

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.

Also Liked

kip

kip

ex_cldr Core Team

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:

:ftp.open('my.ftps.server', [what: 'options', go: 'here?']
monkeypy

monkeypy

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

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

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

NobbZ

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:.

krp

krp

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

Where Next?

Popular in Questions Top

senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
dokuzbir
Hello, I am trying to convert my lists to string without losing brackets.For start i have 3 map. They look like these buyer = %{ id: ...
New
gonzofish
I’m currently trying to understand how to join three tables using Ecto. All the examples I’ve seen use 2, so maybe I’m just missing somet...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

Other popular topics Top

srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 45766 226
New
AstonJ
You’re a programmer, so you don’t need spoon feeding with the conventional drivel about “this is an integer.” No. You need to know what’s...
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
magnetic
Hey :wave:t3: Elixir community, I’ve been learning Elixir, and working on some side projects. My editor of choice is VSCode, and althoug...
New

We're in Beta

About us Mission Statement