'Uploads data from an interator in fixed sized chunks to S3
:param response: Response object from the initial POST request
:type response: :class:`RawResponse`
:param data: Any data from the initial POST request
:type data: ``str``
:param iterator: The generator for fetching the upload data
:type iterator: ``generator``
:param object_path: The path of the object to which we are uploading
:type object_name: ``str``
:param blob_type: The blob type being uploaded
:type blob_type: ``str``
:param lease: The lease object to be used for renewal
:type lease: :class:`AzureBlobLease`
:keyword calculate_hash: Indicates if we must calculate the data hash
:type calculate_hash: ``bool``
:return: A tuple of (status, checksum, bytes transferred)
:rtype: ``tuple``'

def _upload_in_chunks(self, response, data, iterator, object_path, blob_type, lease, calculate_hash=True):

    if (response.status != httplib.CREATED):
        raise LibcloudError(('Error    initializing    upload.    Code:    %d' % response.status), driver=self)
    data_hash = None
    if calculate_hash:
        data_hash = self._get_hash_function()
    bytes_transferred = 0
    count = 1
    chunks = []
    headers = {}
    lease.update_headers(headers)
    if (blob_type == 'BlockBlob'):
        params = {'comp': 'block'}
    else:
        params = {'comp': 'page'}
    for data in read_in_chunks(iterator, AZURE_CHUNK_SIZE):
        data = b(data)
        content_length = len(data)
        offset = bytes_transferred
        bytes_transferred += content_length
        if calculate_hash:
            data_hash.update(data)
        chunk_hash = self._get_hash_function()
        chunk_hash.update(data)
        chunk_hash = base64.b64encode(b(chunk_hash.digest()))
        headers['Content-MD5'] = chunk_hash.decode('utf-8')
        headers['Content-Length'] = content_length
        if (blob_type == 'BlockBlob'):
            block_id = base64.b64encode(b(('%10d' % count)))
            block_id = block_id.decode('utf-8')
            params['blockid'] = block_id
            chunks.append(block_id)
        else:
            headers['x-ms-page-write'] = 'update'
            headers['x-ms-range'] = ('bytes=%d-%d' % (offset, (bytes_transferred - 1)))
        lease.renew()
        resp = self.connection.request(object_path, method='PUT', data=data, headers=headers, params=params)
        if (resp.status != httplib.CREATED):
            resp.parse_error()
            raise LibcloudError(('Error    uploading    chunk    %d.    Code:    %d' % (count, resp.status)), driver=self)
        count += 1
    if calculate_hash:
        data_hash = data_hash.hexdigest()
    if (blob_type == 'BlockBlob'):
        self._commit_blocks(object_path, chunks, lease)
    response.headers['content-md5'] = None
    return (True, data_hash, bytes_transferred)
