How To Save Rails From Processing Large XML Messages

There are many actions in our rails application that perform regular webapp actions. But we have one action that takes a large XML file. I would like the rails not to parse the XML in params. Instead, I would like to get the URL parameters (/ documents / {id} / action) and then write the xml file to a specific directory. How do I get Rails to process it?

How to determine the action for this?

def handle_xml
   # what to put here
end

Downloading is done using Content-Type: application / xml. This is a single file, not part of a multi-page form. The rounding operator will look like this:

curl-H 'Accept: application/xml' -H 'Content-Type: application/xml' -X POST -d '<?xml version="1.0" encoding="UTF-8"?><test></test>' http://0.0.0.0:3000/controller/handle_xml
+3
source share
4 answers

, XML- -, ParamsParser .

, ParamsParser , - xml. params_parser.rb .

RoR, ,

, , google "Sanitizing POST params with custom Rware middleware" .

+5

. , Rails , .

XML Rails. XML- (resque). , . /-. Rails POST. request.raw_post.

+1

The action is to get it as a file (by multiphase loading the form), and then save it as a temporary file for you.

0
source

Have you tried to send an XML file with one variable in the http uri request? So something like

@xml_file = xml..xml...xml...

parameters => {
  query => {
    xml_file => @xml_file
  }
}
Httparty.post("url", parameters)

Then in your method:

def handle_xml
  @xml_file = params[:xml_file]
  @xml_file.save (or whatever you want here..)
end
0
source

Source: https://habr.com/ru/post/1767632/


All Articles