class Azure::BlobService

Public Instance Methods

create_block_blob(container, blob, content_or_filepath, options={})
create_block_blob_with_chunking(container, blob, content_or_filepath, options={}) click to toggle source

def get_blob_with_chunking(container, blob, option)

end

alias_method :get_blob_without_chunking, :get_blob alias_method :get_blob, :get_blob_with_chunking

# File lib/azure-contrib/blob_service.rb, line 58
def create_block_blob_with_chunking(container, blob, content_or_filepath, options={})
  chunking = options.delete(:chunking)
  if chunking
    filepath = content_or_filepath
    block_list = upload_chunks(container, blob, filepath, options)

    unless block_list
      puts "EMPTY BLOCKLIST!"
      return false
    end

    puts "Done uploading #{block_list.size} blocks, committing ..."
    options[:blob_content_type] = options[:content_type]
    commit_blob_blocks(container, blob, block_list, options)
    puts "done."
  else
    content = content_or_filepath
    create_block_blob_without_chunking(container, blob, content, options)
  end
end
Also aliased as: create_block_blob
create_block_blob_without_chunking(container, blob, content_or_filepath, options={})
Alias for: create_block_blob
upload_chunks(container, blob, filepath, options = {}) click to toggle source

The maximum size for a block blob is 200 GB, and a block blob can include no more than 50,000 blocks. msdn.microsoft.com/en-us/library/azure/ee691964.aspx

# File lib/azure-contrib/blob_service.rb, line 81
def upload_chunks(container, blob, filepath, options = {})
  counter = 1
  futures = []
  pool    = BlockActor.pool(size: 10, args: [self, container, blob, options])

  open(filepath, 'rb') do |f|
    f.each_chunk() {|chunk|
      block_id = counter.to_s.rjust(5, '0')
      futures << pool.future.upload(block_id, chunk)
      counter += 1
    }
  end

  block_list = futures.map(&:value)
  pool.terminate
  return block_list
end