curationexperts/sufia — pull request #9 by jeremyf (2013-01-22 16:24:31+00:00)
Title: Updating file extraction for files#create action

When updating to Hydra 5.3 for Sufia, I noticed our installation was
sending the following params:

```
{:files => ["","", ]}
```

instead of the expected:

```
{:files => []}
```

I've updated how the file is extracted from the params[:file]. I have
also added the :unprocessable_entity status as that is a more customary
HTTP status on failure (for javascript requests sending 200 status when
there is an error may confuse the javascript client listening to the
request)

What I have been able to determine is that the `input[name="files[]"]`
element of `./app/views/generic_files/_multiple_upload.html.erb` are
being captured as part of the form serialization and posting.

I was working in Chrome, and the "Select Folder..." option was visible.
When I would click upload, I would get:

```
{:files => ["","", ]}
```

If I removed the conditional logic for Chrome, and didn't render the
second `input[name="files[]"]` for directories, I ended up POSTing the
following:

```
{:files => ["", ]}
```

I tried simply renaming those elements to my_files[], but then the
uploader failed, as it was using the name property to build the form
for submission.