# Upload File Using Net::HTTP to ROR App

**URL:** <https://www.ruby-forum.com/t/upload-file-using-net-http-to-ror-app/104519>\
**Category:** Rails\
**Created:** [May 18, 2007, 11:04pm UTC](https://www.ruby-forum.com/t/upload-file-using-net-http-to-ror-app/104519 "2007-05-18T23:04:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![billbell52](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ce73a5/32.png) [@billbell52](https://www.ruby-forum.com/u/billbell52)\
**Post date:** [May 18, 2007, 11:04pm UTC](https://www.ruby-forum.com/t/upload-file-using-net-http-to-ror-app/104519/1 "2007-05-18T23:04:23Z")

</div>

I can submit a zip file using a form to an ROR application. But I  
need to be able to do this with a program so I am planning on using  
Net::HTTP. I am debugging it on a PC using Webrick. I create a  
multipart file (shown below). I use the following command to send the  
file.

response = Net::HTTP.start(“localhost”, 3000).post("/upload/upload",  
query, “Content-type” =\> “multipart/form-data; boundary=” + boundary +  
" " )

There is a controller called app/controllers/upload\_controller.rb.  
There is method in the controller called upload.

For some reason the server cannot find /upload/upload. Here is a  
truncated error log. I have tried everything I know to try. Any  
ideas on this.

#\<TypeError: can’t dup NilClass\>  
[“c:/ruby185/lib/ruby/1.8/cgi.rb:1057:in `dup’”, "c:…

[2007-05-18 15:54:40] ERROR `/upload/upload’ not found.  
127.0.0.1 - - [18/May/2007:15:54:40 Central Standard Time] “POST /  
upload/upload  
HTTP/1.1” 404 283

- -\> /upload/upload

query is the info below. I tried various mime\_types like application/  
zip etc.

–349832898984244898448024464570528145  
Content-Disposition: form-data;name=“commit”

Upload file  
–349832898984244898448024464570528145  
Content-Disposition: form-data;name=“entry%5Buser\_name%5D”

billb  
–349832898984244898448024464570528145  
Content-Disposition: form-data;name=“entry%5Bip\_address%5D”

123.123.123.123  
–349832898984244898448024464570528145  
Content-Disposition: form-data; name=“entry%5Bzip  
%5D”;filename=“test\_yaml.zip”  
Content-Transfer-Encoding: binary  
Content-Type:test/plain

PK DQ°6zzÖžÅ test.yamlåTMoÛ0½aÈàzO ·Hšh—¥Ãvêi(0E!  
ÈÝ(•%W’[¤¿~”­xëê†aäËäããGÈ­lÃw,wŸ¿À·Î`˜ÏxåQFT¢\<r¸ÒÆÀC¸Gƒ2ÿ|  
ÀuÄ&¿Àa"iÕ¹¨Y»J(ùH¥Dmä=‡è;Ì  
‘G×E4Á­‘îQè³•r4hcfî¹© QDR|H\_!Ê¦…sÆ.lµ(Ö7ãlÃ£GÆ†@âjeÜOä€“#kAjFtJ.Áµ6Hr\_(bs¹ÞÒ{3ÚJjYÀÉ0%  
£ñØRØõî«¸ÞýM©wâ }ÐÎN…f‡b„¨]™¬Q«ßQ\>t­Óéãà4ºWQI\>9™‡CrdÉÅŒ£  
(Ñp¨œ;œœ­z_FS?†\< ¿Ç¯š¶ÛŒT®É£®µ’æÔ•lê¬~ìðíî¼³4ý²w-MÀé­  
\<UòOky{7Ÿýíeö7¸ÎW$T!ÅÚp´UoË•¯—lÙäÚ_¢öNuU$=øzy¶r¸ë!êÏò…émSZói\>]\*¡Õ‰Ù=[ôJ:Vå§¨—ÄK÷jLVœÑcvç§’â^a —„žÒÿä’PK DQ  
°6zzÖžÅ ¶ test.yamlPK 7  
ì–349832898984244898448024464570528145–
