'Creates or overwrites blobs.'

def StoreBlobs(self, contents, token=None):

    contents_by_digest = {hashlib.sha256(content).hexdigest(): content for content in contents}
    urns = {self._BlobUrn(digest): digest for digest in contents_by_digest}
    mutation_pool = data_store.DB.GetMutationPool(token=token)
    existing = aff4.FACTORY.MultiOpen(urns, aff4_type=aff4.AFF4MemoryStreamBase, mode='r', token=token)
    for (blob_urn, digest) in urns.iteritems():
        if (blob_urn in existing):
            logging.debug('Blob    %s    already    stored.', digest)
            continue
        fd = aff4.FACTORY.Create(blob_urn, aff4.AFF4UnversionedMemoryStream, mode='w', token=token, mutation_pool=mutation_pool)
        content = contents_by_digest[digest]
        fd.Write(content)
        fd.Close()
        logging.debug('Got    blob    %s    (length    %s)', digest, len(content))
    mutation_pool.Flush()
    return contents_by_digest.keys()
