VSTS 0.1.24
Fixes client upload methods.
Example method to upload a file and link it as a work item attachment:
def upload_work_item_attachment(wit_client, work_item_id, file_name, callback=None):
# upload file / create attachment
with open(file_name, 'r+b') as file:
# use mmap, so we don't load entire file in memory at the same time, and so we can start
# streaming before we are done reading the file.
mm = mmap.mmap(file.fileno(), 0)
attachment = wit_client.create_attachment(mm, file_name=file_name, callback=callback)
# Link Work Item to attachment
patch_document = [
JsonPatchOperation(
op="add",
path="/relations/-",
value={
"rel": "AttachedFile",
"url": attachment.url
}
)
]
wit_client.update_work_item(patch_document, work_item_id)