socketry / async-http

MIT License
320 stars 46 forks source link

Add an example of POSTing a file with a chunked encoding #16

Closed ainar-g closed 5 years ago

ainar-g commented 5 years ago

I couldn't quite figure out how to do that. Async::HTTP::Body::Chunked seems to be used in reading a chunked response, not sending it to a remote server. It would be nice to have an example.

ioquatix commented 5 years ago

Do you need to explicitly use chunked encoding? Can you give me a better idea of what you are trying to do?

ainar-g commented 5 years ago

Basically, I want to upload Rails's Tempfile into a third-party server without reading the whole file into RAM. Right now I am using body_stream from the native Net::HTTP.

ioquatix commented 5 years ago

You can use https://github.com/socketry/protocol-http/blob/master/lib/protocol/http/body/file.rb or implement something similar. It should stream in chunks.