Skip to content

Instantly share code, notes, and snippets.

@naaman
Last active August 29, 2015 14:02
Show Gist options
  • Save naaman/9a0f6b7b7b89ffc1635a to your computer and use it in GitHub Desktop.
Save naaman/9a0f6b7b7b89ffc1635a to your computer and use it in GitHub Desktop.
busl
$ export STREAM_ID=$(curl busl.herokuapp.com/streams -X POST)
$ ruby reader.rb $STREAM_ID
# In a separate console
$ ruby chunker.rb $STREAM_ID /path/to/file
# watch all the hustle and bustle
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
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment