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

fileupload support should also respect [] for multifiles #128

Closed
casualjim opened this issue Sep 5, 2011 · 1 comment
Closed

fileupload support should also respect [] for multifiles #128

casualjim opened this issue Sep 5, 2011 · 1 comment
Assignees
Labels
Milestone

Comments

@casualjim
Copy link
Member

fileupload support should also respect [] for multifiles

@casualjim
Copy link
Member Author

07:02 deteego: does anyone know if there is support for html5 multi file upload for scalatra?
07:49 casualjim: deteego: there is no explicit support for multi file upload, but I think it will just work
08:02 deteego: casualjim: it actually seems to be an issue on the client side, not the server
08:44 deteego: casualjim: for some reason (and I have no idea if this is an issue with Java's HTTP servlet), the post data cannot be retrieved when I attempt to use this plugin
08:45 deteego: casualjim: http://aquantum-demo.appspot.com/file-upload
08:52 casualjim: are you using the fileupload support in scalatra/
08:52 casualjim: ?
08:52 casualjim: it has multipart suppport and that's what you need
08:59 deteego: casualjim: yes I am, and I am not getting anything
09:00 deteego: casualjim: which is the problem
09:04 deteego: casualjim: I am getting a key not found "files"
09:04 deteego: casualjim: firebug has the post data as this Content-Disposition: form-data; name="files[]"; filename="add photos button1.png" Content-Type: image/png
09:05 deteego: casualjim: and this is what I have simply for detecting it for (i <- 0 until fileMultiParams("files").length) { println("rwar") }
09:07 deteego: casualjim: actually nvm i got it
09:08 deteego: casualjim: some servers need the name to be name to end in an "[]" to be processed as an array
09:08 deteego: casualjim: that is not the case for scalatra
09:08 casualjim: but it should work with []
09:09 casualjim: if not my app is really broken
09:09 deteego: casualjim: so in my case, the paramater actually was files[] and not files
09:09 deteego: casualjim: so it works with files[]
09:09 casualjim: https://github.com/scalatra/scalatra/blob/develop/core/src/main/scala/org/scalatra/util/MultiMap.scala#L15
09:09 casualjim: we compensate for []
09:10 deteego: casualjim: what version of scalatra is this in?
09:10 deteego: casualjim: because it didn't work in my case
09:10 casualjim: which version are you using?
09:11 deteego: casualjim: 2.0.0-SNAPSHOT
09:11 casualjim: there it works for sure
09:11 casualjim: but apparently files are treated differently
09:11 deteego: hmmmm
09:12 casualjim: https://github.com/scalatra/scalatra/blob/develop/fileupload/src/main/scala/org/scalatra/fileupload/FileUploadSupport.scala#L103
09:12 deteego: casualjim: well for that version, in files it doesn't detect the [], and treats it as a different parameter name
09:12 casualjim: yes
09:13 deteego: casualjim: apparently (for PHP, no idea if its the case for scalatra), the [] is required when multiple files are sent over a post
09:13 deteego: casualjim: else if you dont have the [], the server will only detect the first file
09:13 casualjim: yes
09:13 casualjim: for ruby it is too
09:13 casualjim: and IIRC for python as well
09:13 deteego: casualjim: so for scalatra, will it detect multiple files without the []?
09:13 casualjim: but it depends on the http parser
09:13 casualjim: yes
09:13 casualjim: if you repeat files a few times
09:14 casualjim: files=422.png&files=456.png
09:14 deteego: casualjim: ok thanks, thats probably something you should mention on the scalatra site if you haven't already
09:15 casualjim: created an issue for it

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

No branches or pull requests

2 participants