Fix chmod code to support ActionDispatch::Http::UploadedFile