The current Ruby Azure SDK does indeed have methods for doing chunked uploads, but there are no usage examples anywhere and everything in the specs is a mock, which doesn't really help.
Getting chunked uploads to work is so fiddly that this is absolutely something that should be included in the library. It took me a number of hours to get this right and I hope this code snippet helps.
Here is a very basic usage example:
class ::File
def each_chunk(chunk_size=2**20)
yield read(chunk_size) until eof?
end
end
container = 'your container name'
blob = 'your blob name'
block_list = []
service = Azure::BlobService.new
counter = 1
open('path/to/file', 'rb') do |f|
f.each_chunk {|chunk|
block_id = counter.to_s.rjust(5, '0')
block_list << [block_id, :uncommitted]
# You will likely want to get the MD5 for retries
options = {
content_md5: Base64.strict_encode64(Digest::MD5.digest(chunk)),
timeout: 300 # 5 minutes
}
md5 = service.create_blob_block(container, blob, block_id, chunk, options)
counter += 1
}
end
service.commit_blob_blocks(container, blob, block_list)
Give me a couple of days and I should have something more reasonably encapsulated committed to https://github.com/dmichael/azure-contrib