[erlang-questions] httpc request - stream to file

Eric Meadows-Jönsson eric.meadows.jonsson@REDACTED
Mon Oct 12 20:11:51 CEST 2015


Delete the file before calling httpc:request.

On Mon, Oct 12, 2015 at 11:16 AM, Yury Shefer <shefys@REDACTED> wrote:

> Hi,
>
> I'm studying Erlang and have a simple question. In my http request
> function i'm using stream to save the output to the file. The question is
> how to replace the file content instead of adding additional data to it?
>
> fetch_db_ver() ->
> httpc:request(get,
> {"http://www.domain.com/CURRENTDBVERSION",[]},
> [],
> [{stream, "CURRENTDBVERSION"}]
> ).
>
> current_version() ->
> file:read_file("CURRENTDBVERSION").
>
>
> So, instead of
>
> 32154810
>
> I'm getting  "3215334632153346321533463215334632154810"
>
> 19> db:current_version().
> {ok,<<"3215334632153346321533463215334632154810">>}
>
> --
> Thanks a lot,
> Yury.
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>


-- 
Eric Meadows-Jönsson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20151012/0cd48010/attachment.htm>


More information about the erlang-questions mailing list