From: Brian Candler Date: 2008-10-24T23:45:09+09:00 Subject: Re: Errors while file uploading thr 'net/http' or 'rest-open-uri' client > http://www.realityforge.org/articles/2006/03/02/upload-a-file-via-post-with-net-http That's the document I was going to point you at. It Works For Me [TM], for an application which expects to get a multipart/form-data POST. Now, what you are doing seems very strange; you appear to be form-encoding the Content-Type and Content-Transfer-Encoding headers and sending them in the body instead of sending them as HTTP headers. Furthermore, the place you are posting to is http://something/file/uploads.xml which looks like you should be sending an XML document instead of form-encoded data anyway. And you are creating a MIME boundary string too, even though you're not sending it! You should be aware that there are at least three completely different ways of uploading data via a POST: (1) Raw content in the body, such as an image or an XML document (2) application/x-www-form-encoded, where the body consists of name1=value1&name2=value2&... (3) multipart/form-data, where the body consists of multiple MIME sections, one for each parameter in the form [this is the usual case for uploads of "attachments" through a web browser] If you try to use the wrong way of uploading the data, or worse try to mix all three together as you appear to be doing, it will be meaningless to the server. Since there are so many variables and possible things to go wrong, you first need to work out what on earth it is you're trying to do in the first place. You need to work from something concrete, such as: (a) the actual server-side code which receives the data; or (b) a HTML form which successfully uploads the required data via a browser; or (c) a tcpdump of a successful upload from some other client; or (d) a hard-and-fast accurate technical specification for the format the server is expecting to receive. Then at least it should be possible to work out which of formats (1), (2) or (3) you need to send, and then you can google for some working code which does that. Brian. -- Posted via http://www.ruby-forum.com/.