# Fixing Multipart Uploads in Rack for Ruby 1.9

> Patch your Rack installation after seeing an 'invalid byte sequence in US-ASCII' error.

- Author: Curtis Miller
- Published: 2009-09-28
- Categories: ruby, rails, how-to
- Canonical URL: https://millarian.com/posts/fixing-multipart-uploads-in-rack-for-ruby-1-9/

There is a slight problem in Rack 1.0.0 that causes a fatal error to be produced when uploading files \<= 110K in size. You may need to patch Rack if you see the following error when uploading a file (I saw it with Paperclip):

[Code sample on GitHub Gist](https://gist.github.com/197155)

**Here's what you do to patch Rack:**

[Code sample on GitHub Gist](https://gist.github.com/197215)

You should now be back in business. Hopefully it won't be too long before an update is released for Rack that includes the patch.

Happy uploading!

## References

- [Rails Ticket #2497: Rack in Rails 2.3.2 throws fatal error with small uploads](https://rails.lighthouseapp.com/projects/8994/tickets/2497-rack-in-rails-232-throws-fatal-error-with-small-uploads)
- [Rack commit log: Fix multipart uploads on 1.9](http://github.com/rack/rack/commit/44ed4640f077504a49b7f1cabf8d6ad7a13f6441)
- [Ruby NYC: paperclip triggering a “invalid byte sequence in US-ASCII” ruby 1.9 rails 2.3](http://rubynyc.wordpress.com/ruby-1-9-1/paperclip-triggering-a-invalid-byte-sequence-in-us-ascii/)
