multi-part post problem - every single field is a file

9 views
Skip to first unread message

nahum

unread,
Sep 1, 2011, 4:55:18 PM9/1/11
to wellr...@googlegroups.com
We have a rather perplexing problem. When a client is posting a file to our API each field is coming through as a file, so 'name', 'description', 'quantity' etc are all being stored as files on disk with the correct data in the file.

I don't believe it's a rails problem as the client is using Cold Fusion (I know!!) and can successfully send the same data as a curl call. Before I go and spend a bunch of time trying to fix it I was wondering if anyone here had hit upon this??  Presumably the request is being badly formatted, I've just got to figure out how.

For what it's worth, we're on rails 2.3.x and have more gems than god.

cheers,
nahum

Nahum Wild

unread,
Sep 1, 2011, 5:17:07 PM9/1/11
to wellr...@googlegroups.com
so it looks like it's this solution:


anyone know if this has been fixed in a later version of rails?

--nahum

--
You received this message because you are subscribed to the Google Groups "WellRailed" group.
To view this discussion on the web visit https://groups.google.com/d/msg/wellrailed/-/ckyPEoJSwO0J.
To post to this group, send email to wellr...@googlegroups.com.
To unsubscribe from this group, send email to wellrailed+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/wellrailed?hl=en.

Y. Thong Kuah

unread,
Sep 1, 2011, 6:00:30 PM9/1/11
to wellr...@googlegroups.com
The problem is probably in Rack, so Rails 2.3.x could be Rack 1.1 or Rack 1.0

--
You received this message because you are subscribed to the Google Groups "WellRailed" group.
To view this discussion on the web visit https://groups.google.com/d/msg/wellrailed/-/ckyPEoJSwO0J.
To post to this group, send email to wellr...@googlegroups.com.
To unsubscribe from this group, send email to wellrailed+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/wellrailed?hl=en.



--
Best regards,
Y. Thong Kuah


Nahum Wild

unread,
Sep 1, 2011, 6:07:03 PM9/1/11
to wellr...@googlegroups.com
yeah, Koz just helped me out. It is rake and appears to be fixed in later versions, although we can't upgrade.

What it's doing is this:

if content_type || filename

  body = Tempfile.new("RackMultipart")

  body.binmode  if body.respond_to?(:binmode)

end


passing the content type for non-file fields is actually valid, so using that as a 'is it a file' test is wrong and currently biting us.

--nahum

Y. Thong Kuah

unread,
Sep 1, 2011, 6:14:08 PM9/1/11
to wellr...@googlegroups.com
That should be easy to monkey-patch then ;)

Nahum Wild

unread,
Sep 1, 2011, 6:15:34 PM9/1/11
to wellr...@googlegroups.com
indeed.

Glen Barnes

unread,
Sep 1, 2011, 9:07:55 PM9/1/11
to wellr...@googlegroups.com

I don't believe it's a rails problem as the client is using Cold Fusion (I know!!) and can successfully send the same data as a curl call.

We have a bunch of stuff in CF at Realestate.co.nz and although we don't use Rails there we have got the CF stuff talking to other parts of our system using API's. One of the things we found was that CF's default JSON handling is next to useless and that goes for a lot of CF's libraries. So one thing I would check is what libraries they are using on their end to communicate with your service and see if there are known issues with those. 

Glen

Nahum Wild

unread,
Sep 1, 2011, 9:19:40 PM9/1/11
to wellr...@googlegroups.com
the problem is only evident on requests where they are sending multi-part data. and this is exactly the problem (http://stackoverflow.com/questions/1947315/load-testing-multipart-form/1953242#1953242) Which is a bug in Rack that's been fixed in a newer version than what we are using.

fwiw, the client has written their own JSON parser. good times :-)

--nahum

--
You received this message because you are subscribed to the Google Groups "WellRailed" group.
To view this discussion on the web visit https://groups.google.com/d/msg/wellrailed/-/C-5XbC9Swp4J.
Reply all
Reply to author
Forward
0 new messages