I’ve been quite annoyed with the ignorance of people who keep telling every other fucking person that Rails blocks on file upload. Guess what, I’ve got a news for you !!!
You’re fucking wrongBut things don’t stop here. One of them went ahead, tested it, and came back to me to let me know “Rails does block on file uploads.” Here’s one more news..
You don’t know how to fucking testHere are the steps to realize Rails does not block on file uploads :
Stop reading this book :
| 1 2 3 | null:Rails lifo$ rails fileuploads null:Rails lifo$ cd fileuploads/ null:fileuploads lifo$ script/generate controller upload index |
Make your RAILS_ROOT/app/views/upload/index.html.erb look something like below :
| 1 2 3 4 5 | <% form_tag({}, { :multipart => true }) do %> <label for="file">File to Upload</label> <%= file_field_tag "file" %> <%= submit_tag %> <% end %> |
Now, generate a big fat file ( YMMV ) for testing purpose :
| null:fileuploads lifo$ dd if=/dev/random of=out.txt bs=1000000 count=100 |
I had written this article at least 6 months ago, but never published. Don’t take it personally.
by Genís