Hapi: How to write tests for file upload?

Created on 15 Apr 2014  路  4Comments  路  Source: hapijs/hapi

Can someone put up an entire example with server.inject for testing multipart file uploads? All the examples include contents that are hard coded.

It would be great to see one referencing a file in the same folder...lets call it example.pdf or example.jpg

It would be great to see one with a jpg or pdf and how they got the file contents to appear in the test case as well.

support

All 4 comments

Something like https://github.com/spumko/hapi/blob/master/test/payload.js#L1166-L1167 but then take the payload form FormData and pass it to inject. Sorry but explaining how to encode http binary content is outside the scope.

link now leads to new content. Fix please.
Want to know how to make upload

https://github.com/spumko/hapi/blob/master/test/payload.js#L1166-L1167

@jt3k Took me about 15 seconds to find the relevant code. Please try to answer your own question and then post a helpful link here instead of waiting for others to answer the question for you.

https://github.com/hapijs/hapi/blob/5b8c5ff48e8ff7b9642089a84fae42d22e182c44/test/payload.js#L622-L678

@flushentitypacket Your answer is no longer relevant. Thank you for attention.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

midknight41 picture midknight41  路  4Comments

shamsher31 picture shamsher31  路  5Comments

foobar1123 picture foobar1123  路  3Comments

jeffbski picture jeffbski  路  5Comments

leore picture leore  路  3Comments