def _init_document(self, data, mime_type):
"""Upload the data using the documents API."""
filename = 'upload-{0}{1}'.format(uuid4(), guess_extension(mime_type))
document = self.client.documents.create(filename, len(data))
cursor = 0
while cursor < len(data):
chunk = data[cursor:cursor + self.chunk_size]
document.upload(cursor, cursor + len(chunk) - 1, chunk)
cursor += len(chunk)
self._init_url(document.uri)
评论列表
文章目录