Last active
August 29, 2015 14:02
-
-
Save naaman/9a0f6b7b7b89ffc1635a to your computer and use it in GitHub Desktop.
busl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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