Skip to content

Instantly share code, notes, and snippets.

@abshkd
Last active May 12, 2019 07:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abshkd/68b828b42fa8df50fb6fe0156172de97 to your computer and use it in GitHub Desktop.
Save abshkd/68b828b42fa8df50fb6fe0156172de97 to your computer and use it in GitHub Desktop.
# coding: utf-8
# In[2]:
from base64 import b64encode
import json
# In[3]:
with open("test",'rb') as contents:
encoded_file = b64encode(contents.read())
# In[4]:
attachment_json = {
'container_id': 12,
'file_content': encoded_file.decode('utf-8'),
'file_name': 'binary.dat',
'metadata': {
'contains': [
'vault id'
]
}
}
r = requests.post('https://192.168.88.181/rest/container_attachment', auth= ('',AUTH_TOKEN), data=data, verify=False)
#use the returned vault file info and container id to add an artifact.
add_attachment_json = {
"artifacts" : [
{
"label" : "file attachment",
"cef" : {
"vaultId" : r.json()['vault_id'],
"fileHashMd5" : r.json()['hash']
}
}
]
}
update_container = requests.post('https://192.168.88.181/rest/container/12', auth= ('',AUTH_TOKEN), data=json.dumps(add_attachment_json), verify=False)
update_container.json()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment