Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Posting an array of uploaded files #3

Closed
louismrose opened this issue Mar 22, 2010 · 3 comments
Closed

Posting an array of uploaded files #3

louismrose opened this issue Mar 22, 2010 · 3 comments

Comments

@louismrose
Copy link
Contributor

Hi,

Thanks so much for Rack::Test; it's an incredibly useful library for me.

I think I might have uncovered a bug. I'd like to be able to specify an array of file uploads as params to a post request:

foo = Rack::Test::UploadedFile.new('foo.txt', 'text/plain')
bar = Rack::Test::UploadedFile.new('bar.txt', 'text/plain')

post "photos", :photo => { :file => [foo, bar]}

But in the controller, I receive the following params:

{"photo"=>{"file"=>[{"foo"=>"", "bar"=>""}]}, "action"=>"create", "controller"=>"photos"}

When posting a single file, the file is available in the params, as expected:

{"photo"=>{"file"=>#<File:/var/folders/QR/QR1Z8LNdGlaaW1vRT-ls2E+++TI/-Tmp-/RackMultipart20100322-9449-1o9a6i1-0>}, "action"=>"create", "controller"=>"photos"}

I'm happy to try a patch, but thought I'd ask whether I'm doing something stupid first!

Thanks very much.

@louismrose
Copy link
Contributor Author

I've looked at this some more, and think it's a problem with Rack::Test::Utils#build_multipart.

I've added some specs for this case and they're passing here:
http://github.com/louismrose/rack-test/commit/9a0eb89956ae8723bf3d270bab6b0c2f81047ed7

I'll also send a pull request :)

@bernd
Copy link

bernd commented May 25, 2010

Any news about this? louismrose's diff also fixes a problem with rails' foo_ids[] parameters for me.

Thanks!

@brynary
Copy link
Collaborator

brynary commented May 26, 2010

Thanks for the patch, Louis. Applied to master.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants