This is just a thought, and may not work but em-http supports file
sending from disk, using the :file => option. It might be possible to
get the same behavior by using an intermidiate IO object such as
StringIO in place of a file name.
buffer = StringIO.new
@http = EventMachine::HttpRequest.new(put_url).put(:file => buffer)
http.stream { |chunk| buffer << chunk }
Then make sure to signal EOF.
--Dan
On Fri, Mar 30, 2012 at 9:30 AM, Andrew Ashbacher
<[email protected]> wrote:
> Hi Matt,
>
> Thanks for the response. I am in fact using EventMachine::HttpRequest.
>
> For the GET request, I am doing the following:
>
> http.stream { |chunk| @listener.send_data chunk }
>
> Inside @listener.send_data, the following occurs:
>
> @http.on_body_data chunk
>
> Where:
>
> @http = EventMachine::HttpRequest.new(put_url).put(put_options)
>
> Is there any blocking occurring here? Also, is there a better way to
> send data to an open PUT request besides using on_body_data?
>
> Thanks again for you help,
> AA
>
>
> On Thu, Mar 29, 2012 at 11:47 PM, Matt Aimonetti
> <[email protected]> wrote:
>>
>> Have you tried to use EM's http client?
>> http://eventmachine.rubyforge.org/EventMachine/Protocols/HttpClient2.html
>>
>> And/or https://github.com/igrigorik/em-http-request
>>
>> It should be pretty straight forward but careful not to block the run loop
>> while writing to S3.
>>
>> -m
>> Sent from my iPhone
>>
>> On Mar 30, 2012, at 0:23, andrewashbacher <[email protected]> wrote:
>>
>> > Hi,
>> >
>> > I'm trying to pipe data from HTTP GET to HTTP POST or PUT using
>> > EventMachine. I created a question on SO (http://stackoverflow.com/
>> > questions/9933697/pipe-data-from-http-get-to-http-post-put). My goal
>> > is to take a source URL (HTTP) and transfer it directly to S3 (via
>> > HTTP PUT) without touching the disk.
>> >
>> > Have any of you done something like this before? And/or have any
>> > hints on what I should Google for? Any help is appreciated.
>> >
>> > Cheers,
>> > Andrew
>> >
>> > --
>> > SD Ruby mailing list
>> > [email protected]
>> > http://groups.google.com/group/sdruby
>>
>> --
>> SD Ruby mailing list
>> [email protected]
>> http://groups.google.com/group/sdruby
>
>
>
>
> --
> Andrew Ashbacher
> [email protected]
> +01 (619) 851-0250
>
> --
> SD Ruby mailing list
> [email protected]
> http://groups.google.com/group/sdruby
--
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby