post - Storing and retrieving photo files from riak through nitrogen using riak-erlang-client -


I am running a Reic cluster of 5 nodes that I connect through a protocol buffer client. I installed the Reac-Ellong-Client as a Nitrogen Plugin as I did the suggestion. I know how to upload files through nitrogen web-framework, after that I try to store them in the ryak database and retrieve them later.

I highlight this highlight on

<> curl -XPUT http: // localhost: 10018 / bucket / images / key / & lt; Image_name & gt; .jpg H 'Content Type: image / jpeg' --data- binary @ & lt; Image_name & gt; .jpg

But it is not fulfilling my needs completely because it also does not use the customer I am using !!

In the picture files of the directory I failed to get them to get my nitrogen

First of all Also help is welcomed. Use the Erlang-Client as a plugin to make Reuters as Nitrogen. Add a dependency like below from rebar.config to your project

  {deps, [{riakc, "1.4.1", {git, "git: //github.com/basho/ Riak-erlang-client ", {tag," 1.4. 1 "}}}]}}.  

Then run in your application

  cd ../../myapp make  

Upload file example Use this source code to get it.

Captures LocalFileName File Path in the Scroll Folder in the Finnish_upload_Event section. Use the file path to read the file.

  Event (_) - & gt; Fine. Start_upload_event (tag) - & gt; Wf: Flash (wf: f ("Started with upload tag (~ p)", [tag])). Finish_upload_event (_Tag, undefined, _, _) - & gt; Wf: Flash ("Please select a file."), OK; Finish_upload_event (_Tag, _FileName, localfilename, _Node) - & gt; {Well, Binary_image} = file: read_file (LocalFileName), %% Riak database {ok, Pid} = open connection riakc_pb_socket: start (DBNode, port, {connect_timeout, TIMEOUT}, auto_reconnect, false}])). New (term_to_binary (my_images), term_to_binary (My_key), Binary_image), %% database Save OK = riakc_pb_socket: put (PID %% bucket where you are asked my_images save your pictures, then riak object obj = make riakc_obj , Obj, []).  

To read the image from the database and display it in the web browser

  -module (image) -include_lib ("nitrogen_core / include / wf. Hrl "). -compile (export_all). Main () - & gt; %% image set content of the WF to: content_type ( "image / png"), {ok, Pid} = riakc_pb_socket: start (DBNode, port, {connect_timeout, TIMEOUT}, auto_reconnect, false}])). Get (PID, term_to_binary (my_images), term_to_binary (My_key), []), %% record image record Binary_image = binary_to_term (riakc_obj: get_value (got went %% database {Well, brought} = read image data from riakc_pb_socket) ), Binary_image event (_) - & gt; Fine.  

your URL in the browser structure image file as

where Image rendering the image file module.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -