Skip to content

Commit

Permalink
Add size parameter to upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Dellweg authored and evgeni committed Dec 12, 2019
1 parent 1f4f681 commit 6308c52
Show file tree
Hide file tree
Showing 7 changed files with 678 additions and 471 deletions.
7 changes: 5 additions & 2 deletions plugins/modules/katello_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,18 @@ def main():

if not content_unit:
if not module.check_mode:
content_upload = module.resource_action('content_uploads', 'create', repository_scope)
size = os.stat(entity_dict['src']).st_size
content_upload_payload = {'size': size}
content_upload_payload.update(repository_scope)
content_upload = module.resource_action('content_uploads', 'create', content_upload_payload)
content_upload_scope = {'id': content_upload['upload_id']}
content_upload_scope.update(repository_scope)

offset = 0

with open(entity_dict['src'], 'rb') as contentfile:
for chunk in iter(lambda: contentfile.read(CONTENT_CHUNK_SIZE), b""):
data = {'content': chunk, 'offset': offset}
data = {'content': chunk, 'offset': offset, 'size': len(chunk)}
module.resource_action('content_uploads', 'update', params=content_upload_scope, data=data)

offset += len(chunk)
Expand Down
222 changes: 131 additions & 91 deletions tests/test_playbooks/fixtures/upload-0.yml

Large diffs are not rendered by default.

160 changes: 94 additions & 66 deletions tests/test_playbooks/fixtures/upload-1.yml

Large diffs are not rendered by default.

222 changes: 131 additions & 91 deletions tests/test_playbooks/fixtures/upload-2.yml

Large diffs are not rendered by default.

156 changes: 92 additions & 64 deletions tests/test_playbooks/fixtures/upload-3.yml

Large diffs are not rendered by default.

226 changes: 133 additions & 93 deletions tests/test_playbooks/fixtures/upload-4.yml

Large diffs are not rendered by default.

156 changes: 92 additions & 64 deletions tests/test_playbooks/fixtures/upload-5.yml

Large diffs are not rendered by default.

0 comments on commit 6308c52

Please sign in to comment.