Skip to content

Commit e41ec79

Browse files
Update files.py
1 parent abc6bd4 commit e41ec79

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

interfax/files.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,24 +54,28 @@ def _init_path(self, data):
5454

5555
def _init_binary(self, data, mime_type):
5656
"""Initialise with binary data."""
57+
self.mime_type = mime_type
58+
self.body = data
59+
5760
if len(data) > self.chunk_size:
5861
return self._init_document(data, mime_type)
5962

60-
self.mime_type = mime_type
61-
self.body = data
63+
6264

6365
def _init_document(self, data, mime_type):
6466
"""Upload the data using the documents API."""
6567
filename = 'upload-{0}{1}'.format(uuid4(), guess_extension(mime_type))
6668
document = self.client.documents.create(filename, len(data))
6769

6870
cursor = 0
71+
counter = 1
6972

7073
while cursor < len(data):
7174
chunk = data[cursor:cursor + self.chunk_size]
72-
75+
print('SENDING CHUNK {}..'.format(counter))
7376
document.upload(cursor, cursor + len(chunk) - 1, chunk)
7477
cursor += len(chunk)
78+
counter += 1
7579

7680
self._init_url(document.uri)
7781

0 commit comments

Comments
 (0)