Last active
May 12, 2019 07:23
-
-
Save abshkd/68b828b42fa8df50fb6fe0156172de97 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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