Skip to content

Instantly share code, notes, and snippets.

@naaman
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save naaman/9a0f6b7b7b89ffc1635a to your computer and use it in GitHub Desktop.

Select an option

Save naaman/9a0f6b7b7b89ffc1635a to your computer and use it in GitHub Desktop.

Revisions

  1. naaman revised this gist Jun 5, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion readme.txt
    Original file line number Diff line number Diff line change
    @@ -3,6 +3,6 @@ $ export STREAM_ID=$(curl busl.herokuapp.com/streams -X POST)
    $ ruby reader.rb $STREAM_ID

    # In a separate console
    $ ruby chunker.rb b7e586c8404b74e1805f5a9543bc516f /path/to/file
    $ ruby chunker.rb $STREAM_ID /path/to/file

    # watch all the hustle and bustle
  2. naaman renamed this gist Jun 5, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. naaman created this gist Jun 5, 2014.
    17 changes: 17 additions & 0 deletions chunker.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    require 'excon'

    file = File.open(ARGV[1], 'rb')

    streamer = lambda do
    file.read(Excon.defaults[:chunk_size]).to_s
    end

    res = Excon.post(
    "http://busl.herokuapp.com/streams/#{ARGV[0]}",
    headers: { CONTENT_TYPE: 'application/octet-stream' },
    request_block: streamer
    )

    puts res.inspect

    file.close
    12 changes: 12 additions & 0 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    require 'excon'

    streamer = lambda do |chunk, remaining_bytes, total_bytes|
    puts chunk
    end

    res = Excon.get(
    "http://busl.herokuapp.com/streams/#{ARGV[0]}",
    response_block: streamer
    )

    puts res.inspect
    8 changes: 8 additions & 0 deletions readme.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    $ export STREAM_ID=$(curl busl.herokuapp.com/streams -X POST)

    $ ruby reader.rb $STREAM_ID

    # In a separate console
    $ ruby chunker.rb b7e586c8404b74e1805f5a9543bc516f /path/to/file

    # watch all the hustle and bustle