Note that there are some explanatory texts on larger screens.

plurals
  1. POcan HTTP multipart/mixed xml part be converted to a Hash when mixed with other parts
    primarykey
    data
    text
    <p>The question is just above the last code snippet. Thank you. (environment details are the end )</p> <p>posts_controller.rb</p> <pre><code>class PostsController &lt; ApplicationController def create @post = Post.new(params[:post]) respond_to do |format| format.xml { render :xml =&gt; @post.to_xml(:include =&gt; [ :assets])} end end </code></pre> <p>posts.rb</p> <pre><code>class Post &lt; ActiveRecord::Base has_many :assets, :as =&gt; :attachable, :dependent =&gt; :destroy end </code></pre> <p>asset.rb</p> <pre><code>class Asset &lt; ActiveRecord::Base belongs_to :attachable, :polymorphic =&gt; true has_attached_file :data, :url =&gt; "/assets/:id", :path =&gt;":rails_root/assets/:id_partition/:style/:basename.:extension" def name data_file_name end def content_type data_content_type end def file_size data_file_size end end </code></pre> <p>now when we post this information</p> <pre><code>POST /posts.xml HTTP/1.1 Accept-Encoding: gzip,deflate Accept: application/xml Content-Type: application/xml User-Agent: Jakarta Commons-HttpClient/3.1 Host: localhost:8080 Content-Length: 60 &lt;post&gt;&lt;body&gt;postbody&lt;/body&gt;&lt;title&gt;post_title&lt;/title&gt;&lt;/post&gt; </code></pre> <p>a post entry gets created and when I post this</p> <pre><code>POST /posts.xml HTTP/1.1 Content-type: multipart/mixed; boundary=---------------------------7d226f700d0 Accept: application/xml,text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2 Cache-Control: no-cache Pragma: no-cache User-Agent: Java/1.6.0_21 Host: 192.168.0.105:8080 Connection: keep-alive Content-Length: 1710 -----------------------------7d226f700d0 content-disposition: form-data; name="post[title]" Content-Length: 10 post_title -----------------------------7d226f700d0 content-disposition: form-data; name="post[body]" Content-Length: 8 postbody -----------------------------7d226f700d0 content-disposition: form-data; name="post[assets_attributes][0][data]"; filename="C:/Users/mv288/files/1.txt" content-type: application/octet-stream ÿþ sample file content -----------------------------7d226f700d0 content-disposition: form-data; name="post[assets_attributes][0][data]"; filename="C:/Users/mv288/Pictures/1.txt" content-type: application/octet-stream ÿþ sample file content -----------------------------7d226f700d0 </code></pre> <p>a new post gets created with 2 file attachments.</p> <blockquote> <p>now the question is, I want to get the following HTTP post ( please notice the xml part before the file attachments) to also create a post with 2 attachments, with no additional changes ( to posts_controller or routes.rb). is that possible?</p> </blockquote> <pre><code>POST /posts.xml HTTP/1.1 Content-type: multipart/mixed; boundary=---------------------------7d226f700d0 Accept: application/xml,text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2 Cache-Control: no-cache Pragma: no-cache User-Agent: Java/1.6.0_21 Host: 192.168.0.105:8080 Connection: keep-alive Content-Length: 1710 -----------------------------7d226f700d0 Content-type: application/xml; charset=UTF-8 Content-Length: 59 &lt;post&gt;&lt;body&gt;postbody&lt;/body&gt;&lt;title&gt;post_title&lt;/title&gt;&lt;/post&gt; -----------------------------7d226f700d0 content-disposition: form-data; name="post[assets_attributes][0][data]"; filename="C:/Users/mv288/files/1.txt" content-type: application/octet-stream ÿþ sample file content -----------------------------7d226f700d0 content-disposition: form-data; name="post[assets_attributes][0][data]"; filename="C:/Users/mv288/Pictures/1.txt" content-type: application/octet-stream ÿþ sample file content -----------------------------7d226f700d0Blockquotetest </code></pre> <p>using jruby 1.5.2/jdk1.6, rails 2.3.4, paperclip-2.3.3 on windows 2007 - 64 bit</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload