cojs / busboy

Busboy multipart parser as a yieldable
154 stars 24 forks source link

multiple="multiple" support #4

Closed tj closed 10 years ago

tj commented 10 years ago

with an option to transform it into an array when more than one are present

jonathanong commented 10 years ago

if you can think of a good api i'll try to tackle it. not 100% sure how multipart works yet

tj commented 10 years ago

here's what i did for connect's but ideally we have a { multiple: true } option since it's a little confusing for people to somethings have an array and sometimes have a single part if you don't opt-in https://github.com/senchalabs/connect/blob/master/lib/middleware/multipart.js#L115

jonathanong commented 10 years ago

i guess you want .fields as an object, right? it's kind of weird because busboy has truncated booleans which i don't know how to handle (i don't know what that even means). right now i just return it as an array.

there's also other stuff. gotta handle cases where people yield between parts.

var part
while (part = yield parser.part()) {
  yield save(part, 'some file.txt') // this could take too long
}

a part can be emitted between part()s.

then people might want the fields before any of the parts (like CSRF, you can validate before handling any streams). not sure how to handle that either except by doing field = yield parser.field(), but then that's annoying because you gotta do while (next = (yield parser.part()) || (yield parser.field())) and then type check.

HOORAY FOR GENERATORS.

tj commented 10 years ago

actually nvm i guess it's not really a concern haha, gotta get my mind out of the non-sync gutter, the .part() stuff should be just fine

jonathanong commented 10 years ago

i think this module is going to be a pain in the ass, just like multipart always is