Record the download of files in Erlang using HTTP

Source: Internet
Author: User

Question title, this is one of the questions asked in a group. is actually the HTTP server uploads the download function. Kyung-Liang answered the solution to the problem.

Ibrowse:start ().
Ibrowse:send_req ("Http://img1.gtimg.com/12/1293/129340/12934049_980x1200_0.jpg", [], get, [], [{save_response_to_ File, True}]).
As normal return:



You can also specify the destination file to save the path: Ibrowse:send_req ("http://img1.gtimg.com/12/1293/129340/12934049_980x1200_0.jpg", [], get, [], [{ Save_response_to_file, "/tmp/test.jpg"}]). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 's answer is concise and clear. How is this problem solved? Yes, it is using the ibrowse framework.  So what is IBrowse? It is the client framework for HTTP.

IBrowse is an HTTP client written in Erlang (ibrowse) is an HTTP agent written using Erlang. )

Project Address: Https://github.com/cmullaparthi/ibrowse

Preparatory work:

1. Download source code

Use Git to get the meta code and execute the command at the terminal:

git clone https://github.com/cmullaparthi/ibrowse.git

2. Compiling source code

Compile the source code using the Rebar build tool:

./rebar Compile

Compiled successfully, the. Beam and. App files are generated under the Ebin folder.

(Note: This is where you put the dependencies of the project, such as: Deps path, in the Retool.config file below rel, also add the corresponding path.) such as:)

If you do not add this location, the dependency is not referenced.

Try: First enter the Shell,./rel/new_push/bin/new_push attach

1> Ibrowse:start ().

Below:

See, put test.jpg picture in the path of/opt/new_push/rel/files (where can be based on the actual to do).

See details:

and view slices:

And this ibrowse and Erlang's own inets have what pros and cons difference, of course, can also use inets to engage.

Record the download of files in Erlang using HTTP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.