-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
multipart api #11
Comments
do you want to go still with this API? I think it's too low level. |
build up my friend! up! |
the high level stuff like piping files etc can be layered on top easily |
minus |
hehe, meh, I'm so user centric now. I usually design top down. On Wed, Jan 4, 2012 at 1:03 PM, TJ Holowaychuk <
Camilo Aguilar |
then you end up with inflexible APIs like |
I agree, but then if you want to be pragmatic. I'd suggest you to release a simple and functional multipart support since it's pretty straight forward to do. Then, you can continue working on a better and more flexible implementation aka low level api and high level api on top. It's fine if you decide to go straight with the latter since I can use my fork in the mean time. Just putting my 2 cents here. |
@visionmedia I'll be nice also to have the high level API like you envisioned it. |
that's probably what mikeal had in mind for request haha and look at it now, it's just one big function. just takes a bit of time that's all |
it was improve in node 0.6.x wasn't it? |
hug |
haha :D this is why I started superagent, didn't want a rushed lame api |
I was giving it more thought to the need of a low level API and I honestly think that we are over engineering the solution. RFC 1867 is really simple and I don't think it will change in the near future. For instance I don't see the value of allowing users to specify custom headers for every part. Also content-type can be determine by superagent, either by the file extension or using libmagic. The only thing that makes sense to me, so far, is allowing to do piping when downloading binary data. I'm still open to discussion though :) BTW, the API that I'm proposing would look like: request.post('/upload')
.set('x-mycustomheader', 'value')
.part('field1', 'value1') //once it finds the first part it assumes content-type: multipart/form-data defining the boundary
.part('field2', 'value2') //a plain field
.part('file', filePath) //a file path, this could be also an array of file paths
.end(function(res) {
//boo
}); |
im just saying there is more to an API than the highest-level. If you need to set a header field then you need a method for that, if you set a content-type then you need a method for that, if you set a content-type based on a filename the you need a method/mime lookup for that. These lower level APIs would be great for testing node apps, crafting multipart requests that reside in memory (node-canvas etc), and they're basically required by the higher level API anyway |
you could say the same thing about node's |
|
hehe, I got it now, I thought you were proposing the API that most users will ultimately be using... |
nope nope |
how did you come up with content-type mixed/related?. It isn't mentioned in RFC 1867. |
"A multipart/related is used to indicate that each message part is a component of an aggregate whole. It is for compound objects consisting of several inter-related components - proper display cannot be achieved by individually displaying the constituent parts." - http://tools.ietf.org/html/rfc2387 |
not sure why im not using multipart/form-data in part.js haha... wth |
one of those sleepy nights i guess |
oh boy hehe, are you serious? the scope of most rest libraries for file uploads is only rfc1867. If you want to support the whole mime standard I'd suggest to create a new project hehe. |
or write bindings for http://spruce.sourceforge.net/gmime/ |
my example isnt even right "mixed/related" it's "multipart/related" hahaha |
just ignore me haha |
nah, no problem. I'm going to review what we have so far and try to make rfc1867 work with your current design, given that you didn't like my big function ^^. I'd say that it's a fair scope for superagent for now. |
or if you want to do it yourself and want to save time just grab pieces from https://github.com/c4milo/superagent/blob/master/lib/node/part.js. It is working and tested with node-formidable |
something like:
auto-assign boundary when
mixed/*
:support nesting
The text was updated successfully, but these errors were encountered: