mamantoha / crest

HTTP and REST client for Crystal
https://mamantoha.github.io/crest/
MIT License
235 stars 14 forks source link

Multipart form with IO as hash value instead of just File #179

Closed cyangle closed 2 years ago

cyangle commented 2 years ago

This is to support upload multiple IO::Memory strings without creating temp files.

Example:

metadata = {
  "owner" => "crystal",
  "id" => "test"
}

pp Crest::Request.post(
  "http://httpbin.org/post",
  {
    "meta.json" => IO::Memory.new(metadata.to_json),
    "file" => File.open("./spec/support/fff.png")
  }
).body

This is just a POC draft. @mamantoha

mamantoha commented 2 years ago

LGTM

cyangle commented 2 years ago

@mamantoha This PR is ready for review.