cmullaparthi / ibrowse

Erlang HTTP client
Other
516 stars 190 forks source link

[Elixir] set `download_dir` #148

Closed bmalum closed 8 years ago

bmalum commented 8 years ago

Thanks for your work - it is the perfect fit for my Elixir Application.

I'm wondering about something:

I want to use ibrowse from Elixir and also download a file. Now I have set the env var via

Application.put_env(:ibrowse, :download_dir, '/Users/bMalum/Downloads') Application.put_env(:ibrowse, 'download_dir', '/Users/bMalum/Downloads')

The file was still created in the working directory ... how can I change it from Elixir?

cmullaparthi commented 8 years ago

You're welcome :-)

Can you specify how exactly you are invoking ibrowse:send_req ?

bmalum commented 8 years ago

{:ok, status, headers, body} = :ibrowse.send_req(url, [{:cookie, cookie}], :get, [], [{:save_response_to_file, filename}])

url = CharList URL cookie = 'login=somesecret' filename = 'some-file.xyz'

cmullaparthi commented 8 years ago

Hmm... looks like ibrowse only saves in the specified download directory only if you haven't specified a filename. If you specify a filename, it assumes it is the full path.

If you really want to do both, the workaround is to ensure that filename is a filename with either an absolute or relative path.

bmalum commented 8 years ago

Ahhh! I will try 😊 update in a few minutes

bmalum commented 8 years ago

Works! 👍 I think it would be nice to find this again in the Docs 😊

Awesome - OpenSource and super fast response! So happy right now!

I ❤️ the Erlang/Elixir community!

cmullaparthi commented 8 years ago

Glad to be of service :-)