I'm trying to output binary data to stdout (to serve some dynamic binary data using Kemal).
Here is a test:
size = File.size( "./img.png" )
slice = Slice( UInt8 ).new( size )
File.open( "./img.png" ) do |file|
file.read_fully( slice )
end
I tried without success:
slice
slice.hexdump
slice.hexstring
slice.to_a
slice.to_s
slice.to_unsafe.value
You can just use
IO#write(Slice)
: