Skip to content

How to post multipart form data? #160

Answered by ioquatix
jakeonfire asked this question in Q&A
Discussion options

You must be logged in to vote

Here is an example of how to post the data directly: https://github.com/socketry/async-rest/blob/ae3d6da90d6fa8383304bfc66d334954e857dcb2/lib/async/rest/wrapper/form.rb#L27-L33

Regarding files, you'll need to construct a multipart body. Actually, there isn't a good mechanism for this but this might be a good start: https://github.com/socketry/multipart-post/blob/2b1235a25bc3ff03d907785caa83f09c69d6f501/lib/multipart/post/multipartable.rb

Doing it in-memory is okay if you have enough memory/swap to do so.

Beyond that, what we should probably introduce is Protocol::HTTP::Multipart which does streaming from disk/memory. multipart-post has most of the pieces but it was primarily designed for N…

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
5 replies
@jakeonfire
Comment options

@jakeonfire
Comment options

@ioquatix
Comment options

@jakeonfire
Comment options

@ioquatix
Comment options

Answer selected by jakeonfire
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants